Adds 2 factor authentication method via second factor security keys over [web authn](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API). Allows a user to authenticate a second factor on login, login-via-email, admin-login, and change password routes. Adds registration area within existing user second factor preferences to register multiple security keys. Supports both external (yubikey) and built-in (macOS/android fingerprint readers).
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
export default Ember.Controller.extend(ModalFunctionality, {
|
|
actions: {
|
|
disableSecurityKey() {
|
|
this.user
|
|
.updateSecurityKey(this.model.id, this.model.name, true)
|
|
.then(response => {
|
|
if (response.error) {
|
|
return;
|
|
}
|
|
this.markDirty();
|
|
})
|
|
.catch(error => {
|
|
this.send("closeModal");
|
|
this.onError(error);
|
|
})
|
|
.finally(() => {
|
|
this.set("loading", false);
|
|
this.send("closeModal");
|
|
});
|
|
},
|
|
|
|
editSecurityKey() {
|
|
this.user
|
|
.updateSecurityKey(this.model.id, this.model.name, false)
|
|
.then(response => {
|
|
if (response.error) {
|
|
return;
|
|
}
|
|
this.markDirty();
|
|
})
|
|
.catch(error => {
|
|
this.onError(error);
|
|
})
|
|
.finally(() => {
|
|
this.set("loading", false);
|
|
this.send("closeModal");
|
|
});
|
|
}
|
|
}
|
|
});
|