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 test
This commit is contained in:
Barış Soner Uşaklı
2023-08-30 19:29:46 -04:00
committed by GitHub
parent 6ae0d207a7
commit 8db13d8e86
14 changed files with 217 additions and 85 deletions

View File

@@ -455,22 +455,6 @@ describe('Controllers', () => {
assert.strictEqual(result.req.session.emailChanged, 1);
});
it('should set email if admin is changing it', async () => {
const uid = await user.create({ username: 'interstiuser3' });
const result = await user.interstitials.email({
userData: { uid: uid, updateEmail: true },
req: { uid: adminUid },
interstitials: [],
});
await result.interstitials[0].callback({ uid: uid }, {
email: 'interstiuser3@nodebb.org',
});
const userData = await user.getUserData(uid);
assert.strictEqual(userData.email, 'interstiuser3@nodebb.org');
assert.strictEqual(userData['email:confirmed'], 1);
});
it('should throw error if user tries to edit other users email', async () => {
const uid = await user.create({ username: 'interstiuser4' });
try {