Adds a second factor landing page that centralizes a user's second factor configuration. This contains both TOTP and Backup, and also allows multiple TOTP tokens to be registered and organized by a name. Access to this page is authenticated via password, and cached for 30 minutes via a secure session.
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
export default Ember.Controller.extend(ModalFunctionality, {
|
|
actions: {
|
|
disableSecondFactor() {
|
|
this.user
|
|
.updateSecondFactor(
|
|
this.model.id,
|
|
this.model.name,
|
|
true,
|
|
this.model.method
|
|
)
|
|
.then(response => {
|
|
if (response.error) {
|
|
return;
|
|
}
|
|
this.markDirty();
|
|
})
|
|
.catch(error => {
|
|
this.send("closeModal");
|
|
this.onError(error);
|
|
})
|
|
.finally(() => {
|
|
this.set("loading", false);
|
|
this.send("closeModal");
|
|
});
|
|
},
|
|
|
|
editSecondFactor() {
|
|
this.user
|
|
.updateSecondFactor(
|
|
this.model.id,
|
|
this.model.name,
|
|
false,
|
|
this.model.method
|
|
)
|
|
.then(response => {
|
|
if (response.error) {
|
|
return;
|
|
}
|
|
this.markDirty();
|
|
})
|
|
.catch(error => {
|
|
this.send("closeModal");
|
|
this.onError(error);
|
|
})
|
|
.finally(() => {
|
|
this.set("loading", false);
|
|
this.send("closeModal");
|
|
});
|
|
}
|
|
}
|
|
});
|