mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 11:45:48 +02:00
User create / registeration queue refactor (#13905)
* feat: add options parameter to User.create
add emailVerification: ('send'|'verify'|'skip') param to User.create to control email verification
add a new method User.createOrQueue(). store options that will be passed to User.create() when registration is accepted in _opts
If there is no password passed to registration queue(SSO register) don't store hashedPassword
removed the isFirstUser hack in user.create, when creating the admin user in install.js passing `emailVerification: 'verify'` to immediately verify the email, same with all the hacks in tests
auth: if an SSO plugin sends back an info object, redirect to root and display the message
* refactor: make function private
* refactor: destruct return
* test: fix flag test
* test: group tests
* feat: show ssoIcon if available in register queue
* add icon/title
This commit is contained in:
@@ -39,9 +39,9 @@ describe('Controllers', () => {
|
||||
});
|
||||
cid = category.cid;
|
||||
|
||||
fooUid = await user.create({ username: 'foo', password: 'barbar', gdpr_consent: true });
|
||||
await user.setUserField(fooUid, 'email', 'foo@test.com');
|
||||
await user.email.confirmByUid(fooUid);
|
||||
fooUid = await user.create({ username: 'foo', password: 'barbar', gdpr_consent: true, email: 'foo@test.com' }, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
adminUid = await user.create({ username: 'admin', password: 'barbar', gdpr_consent: true });
|
||||
await groups.join('administrators', adminUid);
|
||||
@@ -395,9 +395,9 @@ describe('Controllers', () => {
|
||||
it('should remove current email (only allowed if email not required)', async () => {
|
||||
meta.config.requireEmailAddress = 0;
|
||||
|
||||
const uid = await user.create({ username: 'interstiuser5' });
|
||||
await user.setUserField(uid, 'email', 'interstiuser5@nodebb.org');
|
||||
await user.email.confirmByUid(uid);
|
||||
const uid = await user.create({
|
||||
username: 'interstiuser5', email: 'interstiuser5@nodebb.org',
|
||||
}, { emailVerification: 'verify' });
|
||||
|
||||
const result = await user.interstitials.email({
|
||||
userData: { uid: uid, updateEmail: true },
|
||||
@@ -418,9 +418,11 @@ describe('Controllers', () => {
|
||||
it('should require a password (if one is set) for email change', async () => {
|
||||
try {
|
||||
const [username, password] = [utils.generateUUID().slice(0, 10), utils.generateUUID()];
|
||||
const uid = await user.create({ username, password });
|
||||
await user.setUserField(uid, 'email', `${username}@nodebb.org`);
|
||||
await user.email.confirmByUid(uid);
|
||||
const uid = await user.create({
|
||||
username, password, email: `${username}@nodebb.org`,
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
const result = await user.interstitials.email({
|
||||
userData: { uid: uid, updateEmail: true },
|
||||
@@ -441,9 +443,11 @@ describe('Controllers', () => {
|
||||
|
||||
try {
|
||||
const [username, password] = [utils.generateUUID().slice(0, 10), utils.generateUUID()];
|
||||
const uid = await user.create({ username, password });
|
||||
await user.setUserField(uid, 'email', `${username}@nodebb.org`);
|
||||
await user.email.confirmByUid(uid);
|
||||
const uid = await user.create({
|
||||
username, password, email: `${username}@nodebb.org`,
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
const result = await user.interstitials.email({
|
||||
userData: { uid: uid, updateEmail: true },
|
||||
@@ -463,9 +467,11 @@ describe('Controllers', () => {
|
||||
|
||||
it('should successfully issue validation request if the correct password is passed in', async () => {
|
||||
const [username, password] = [utils.generateUUID().slice(0, 10), utils.generateUUID()];
|
||||
const uid = await user.create({ username, password });
|
||||
await user.setUserField(uid, 'email', `${username}@nodebb.org`);
|
||||
await user.email.confirmByUid(uid);
|
||||
const uid = await user.create({
|
||||
username, password, email: `${username}@nodebb.org`,
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
const result = await user.interstitials.email({
|
||||
userData: { uid: uid, updateEmail: true },
|
||||
|
||||
Reference in New Issue
Block a user