core: force uid

This commit is contained in:
undefined committed 2021-06-06 13:24:17 +08:00
1 parent 282d0cdf6b
commit 04b005b825
3 files changed
+8 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.28.21",
"version": "2.28.22",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+1 -1
View File
@@ -232,7 +232,7 @@ class UserModel {
uid: number = 0, regip: string = '127.0.0.1', priv: number = system.get('default.priv'),
) {
const salt = String.random();
if (!uid) {
if (typeof uid !== 'number') {
const [udoc] = await coll.find({}).sort({ _id: -1 }).limit(1).toArray();
uid = Math.max((udoc?._id || 0) + 1, 2);
}
+6 -1
View File
@@ -404,10 +404,15 @@ const scripts: UpgradeScript[] = [
await iterateAllUser((udoc) => user.setPriv(udoc._id, udoc.priv | PRIV.PRIV_SEND_MESSAGE));
return true;
},
null,
// Write builtin users to database
async function _31_32() {
async function _32_33() {
if (!await user.getById('system', 0)) {
await user.create('Guest@hydro.local', 'Guest', String.random(32), 0, '127.0.0.1', PRIV.PRIV_REGISTER_USER);
}
if (!await user.getById('system', 1)) {
await user.create('Hydro@hydro.local', 'Hydro', String.random(32), 1, '127.0.0.1', PRIV.PRIV_USER_PROFILE);
}
return true;
},
];