fix: #8992, set email:confirmed for first admin user

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 6f21832db7
commit 7f5efc3e93

@ -71,8 +71,12 @@ module.exports = function (User) {
userData = results.user; userData = results.user;
const uid = await db.incrObjectField('global', 'nextUid'); const uid = await db.incrObjectField('global', 'nextUid');
const isFirstUser = uid === 1;
userData.uid = uid; userData.uid = uid;
if (isFirstUser) {
userData['email:confirmed'] = 1;
}
await db.setObject('user:' + uid, userData); await db.setObject('user:' + uid, userData);
const bulkAdd = [ const bulkAdd = [
@ -97,8 +101,7 @@ module.exports = function (User) {
} }
const groupsToJoin = ['registered-users'].concat( const groupsToJoin = ['registered-users'].concat(
parseInt(userData.uid, 10) !== 1 ? isFirstUser ? 'verified-users' : 'unverified-users'
'unverified-users' : 'verified-users'
); );
await Promise.all([ await Promise.all([

@ -471,7 +471,7 @@ describe('Hash methods', function () {
db.incrObjectField('testObject12', 'field1', function (err, newValue) { db.incrObjectField('testObject12', 'field1', function (err, newValue) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(arguments.length, 2); assert.equal(arguments.length, 2);
assert.equal(newValue, 1); assert.strictEqual(newValue, 1);
done(); done();
}); });
}); });
@ -480,7 +480,7 @@ describe('Hash methods', function () {
db.incrObjectField('testObject11', 'age', function (err, newValue) { db.incrObjectField('testObject11', 'age', function (err, newValue) {
assert.equal(err, null); assert.equal(err, null);
assert.equal(arguments.length, 2); assert.equal(arguments.length, 2);
assert.equal(newValue, 100); assert.strictEqual(newValue, 100);
done(); done();
}); });
}); });

Loading…
Cancel
Save