mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 05:08:13 +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:
44
test/user.js
44
test/user.js
@@ -72,11 +72,12 @@ describe('User', () => {
|
||||
|
||||
describe('.create(), when created', () => {
|
||||
it('should be created properly', async () => {
|
||||
testUid = await User.create({ username: userData.username, password: userData.password });
|
||||
testUid = await User.create({
|
||||
username: userData.username, password: userData.password, email: userData.email,
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
assert.ok(testUid);
|
||||
|
||||
await User.setUserField(testUid, 'email', userData.email);
|
||||
await User.email.confirmByUid(testUid);
|
||||
});
|
||||
|
||||
it('should be created properly', async () => {
|
||||
@@ -694,12 +695,12 @@ describe('User', () => {
|
||||
let csrf_token;
|
||||
|
||||
before(async () => {
|
||||
const newUid = await User.create({ username: 'updateprofile', email: 'update@me.com', password: '123456' });
|
||||
const newUid = await User.create({
|
||||
username: 'updateprofile', email: 'update@me.com', password: '123456',
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
uid = newUid;
|
||||
|
||||
await User.setUserField(uid, 'email', 'update@me.com');
|
||||
await User.email.confirmByUid(uid);
|
||||
|
||||
({ jar, csrf_token } = await helpers.loginUser('updateprofile', '123456'));
|
||||
});
|
||||
|
||||
@@ -734,9 +735,11 @@ describe('User', () => {
|
||||
let uid;
|
||||
|
||||
it('should update a user\'s profile', async () => {
|
||||
uid = await User.create({ username: 'justforupdate', email: 'just@for.updated', password: '123456' });
|
||||
await User.setUserField(uid, 'email', 'just@for.updated');
|
||||
await User.email.confirmByUid(uid);
|
||||
uid = await User.create({
|
||||
username: 'justforupdate', email: 'just@for.updated', password: '123456',
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
const data = {
|
||||
uid: uid,
|
||||
@@ -772,9 +775,9 @@ describe('User', () => {
|
||||
it('should not change the username to escaped version', async () => {
|
||||
const uid = await User.create({
|
||||
username: 'ex\'ample_user', email: '13475@test.com', password: '123456',
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
await User.setUserField(uid, 'email', '13475@test.com');
|
||||
await User.email.confirmByUid(uid);
|
||||
|
||||
const data = {
|
||||
uid: uid,
|
||||
@@ -1418,9 +1421,12 @@ describe('User', () => {
|
||||
it('should send digests', async () => {
|
||||
const oldValue = meta.config.includeUnverifiedEmails;
|
||||
meta.config.includeUnverifiedEmails = true;
|
||||
const uid = await User.create({ username: 'digest' });
|
||||
await User.setUserField(uid, 'email', 'email@test.com');
|
||||
await User.email.confirmByUid(uid);
|
||||
const uid = await User.create({
|
||||
username: 'digest', email: 'email@test.com',
|
||||
}, {
|
||||
emailVerification: 'verify',
|
||||
});
|
||||
|
||||
await User.digest.execute({
|
||||
interval: 'day',
|
||||
subscribers: [uid],
|
||||
@@ -1893,7 +1899,7 @@ describe('User', () => {
|
||||
privateGroup: groups.create({ name: PRIVATE_GROUP, private: 1 }),
|
||||
hiddenGroup: groups.create({ name: HIDDEN_GROUP, hidden: 1 }),
|
||||
notAnInviter: User.create({ username: 'notAnInviter', password: COMMON_PW }),
|
||||
inviter: User.create({ username: 'inviter', password: COMMON_PW }),
|
||||
inviter: User.create({ username: 'inviter', password: COMMON_PW, email: 'invited@nodebb.org' }, { emailVerification: 'verify' }),
|
||||
admin: User.create({ username: 'adminInvite', password: COMMON_PW }),
|
||||
});
|
||||
|
||||
@@ -1901,12 +1907,10 @@ describe('User', () => {
|
||||
inviterUid = results.inviter;
|
||||
adminUid = results.admin;
|
||||
|
||||
await User.setUserField(inviterUid, 'email', 'inviter@nodebb.org');
|
||||
await Promise.all([
|
||||
groups.create({ name: OWN_PRIVATE_GROUP, ownerUid: inviterUid, private: 1 }),
|
||||
groups.join('administrators', adminUid),
|
||||
groups.join('cid:0:privileges:invite', inviterUid),
|
||||
User.email.confirmByUid(inviterUid),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user