From 7f5efc3e93368fc936db4277e2c877c96a3ed193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 28 Nov 2020 14:43:28 -0500 Subject: [PATCH] fix: #8992, set email:confirmed for first admin user --- src/user/create.js | 7 +++++-- test/database/hash.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/user/create.js b/src/user/create.js index 51e7970e1c..b622a8b5a3 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -71,8 +71,12 @@ module.exports = function (User) { userData = results.user; const uid = await db.incrObjectField('global', 'nextUid'); + const isFirstUser = uid === 1; userData.uid = uid; + if (isFirstUser) { + userData['email:confirmed'] = 1; + } await db.setObject('user:' + uid, userData); const bulkAdd = [ @@ -97,8 +101,7 @@ module.exports = function (User) { } const groupsToJoin = ['registered-users'].concat( - parseInt(userData.uid, 10) !== 1 ? - 'unverified-users' : 'verified-users' + isFirstUser ? 'verified-users' : 'unverified-users' ); await Promise.all([ diff --git a/test/database/hash.js b/test/database/hash.js index 123967b1da..2fb566d8a6 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -471,7 +471,7 @@ describe('Hash methods', function () { db.incrObjectField('testObject12', 'field1', function (err, newValue) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.equal(newValue, 1); + assert.strictEqual(newValue, 1); done(); }); }); @@ -480,7 +480,7 @@ describe('Hash methods', function () { db.incrObjectField('testObject11', 'age', function (err, newValue) { assert.equal(err, null); assert.equal(arguments.length, 2); - assert.equal(newValue, 100); + assert.strictEqual(newValue, 100); done(); }); });