refactor: how admins change emails (#11973)
* refactor: how admins change emails ability for admins to change emails from acp ability for admins to change passwords from acp only users themselves can use /user/<slug>/edit/email group actions in manage users dropdown admins can use the same modal from profile page instead of interstitial to update email add missing checks to addEmail, if email take throw error add targetUid to email change event * test: bunch of baloney * test: remove old testisekai-main
parent
6ae0d207a7
commit
8db13d8e86
@ -0,0 +1,41 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
define('admin/modules/change-email', [
|
||||||
|
'api', 'bootbox', 'alerts',
|
||||||
|
], function (api, bootbox, alerts) {
|
||||||
|
const ChangeEmail = {};
|
||||||
|
|
||||||
|
ChangeEmail.init = function (params) {
|
||||||
|
const modal = bootbox.dialog({
|
||||||
|
message: `
|
||||||
|
<label class="form-label">[[admin/manage/users:new-email]]</label>
|
||||||
|
<input id="newEmail" class="form-control" type="text" value="${utils.escapeHTML(params.email || '')}">
|
||||||
|
`,
|
||||||
|
title: '[[admin/manage/users:change-email]]',
|
||||||
|
onEscape: true,
|
||||||
|
buttons: {
|
||||||
|
cancel: {
|
||||||
|
label: '[[admin/manage/users:alerts.button-cancel]]',
|
||||||
|
className: 'btn-link',
|
||||||
|
},
|
||||||
|
change: {
|
||||||
|
label: '[[admin/manage/users:alerts.button-change]]',
|
||||||
|
className: 'btn-primary',
|
||||||
|
callback: function () {
|
||||||
|
const newEmail = modal.find('#newEmail').val();
|
||||||
|
api.post('/users/' + params.uid + '/emails', {
|
||||||
|
skipConfirmation: true,
|
||||||
|
email: newEmail,
|
||||||
|
}).then(() => {
|
||||||
|
modal.modal('hide');
|
||||||
|
params.onSuccess(newEmail);
|
||||||
|
}).catch(alerts.error);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return ChangeEmail;
|
||||||
|
});
|
Loading…
Reference in New Issue