mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Use second factor for admin confirmation (#14293)
Administrators can use second factor to confirm granting admin access without using email. The old method of confirmation via email is still used as a fallback when second factor is unavailable.
This commit is contained in:
@@ -218,8 +218,15 @@ export default Controller.extend(CanCheckEmails, {
|
||||
grantAdmin() {
|
||||
return this.model
|
||||
.grantAdmin()
|
||||
.then(() => {
|
||||
bootbox.alert(I18n.t("admin.user.grant_admin_confirm"));
|
||||
.then((result) => {
|
||||
if (result.email_confirmation_required) {
|
||||
bootbox.alert(I18n.t("admin.user.grant_admin_confirm"));
|
||||
} else {
|
||||
const controller = showModal("grant-admin-second-factor", {
|
||||
model: this.model,
|
||||
});
|
||||
controller.setResult(result);
|
||||
}
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
|
||||
@@ -99,9 +99,20 @@ const AdminUser = User.extend({
|
||||
});
|
||||
},
|
||||
|
||||
grantAdmin() {
|
||||
grantAdmin(data) {
|
||||
return ajax(`/admin/users/${this.id}/grant_admin`, {
|
||||
type: "PUT",
|
||||
data,
|
||||
}).then((resp) => {
|
||||
if (resp.success && !resp.email_confirmation_required) {
|
||||
this.setProperties({
|
||||
admin: true,
|
||||
can_grant_admin: false,
|
||||
can_revoke_admin: true,
|
||||
});
|
||||
}
|
||||
|
||||
return resp;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@
|
||||
{{/if}}
|
||||
{{#if model.can_grant_admin}}
|
||||
{{d-button
|
||||
class="btn-default"
|
||||
class="btn-default grant-admin"
|
||||
action=(action "grantAdmin")
|
||||
icon="shield-alt"
|
||||
label="admin.user.grant_admin"}}
|
||||
|
||||
Reference in New Issue
Block a user