mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: force uid
This commit is contained in:
1 parent
282d0cdf6b
commit
04b005b825
3 files changed
+10
-5
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
await user.create('Guest@hydro.local', 'Guest', String.random(32), 0, '127.0.0.1', PRIV.PRIV_REGISTER_USER);
|
||||
await user.create('Hydro@hydro.local', 'Hydro', String.random(32), 1, '127.0.0.1', PRIV.PRIV_USER_PROFILE);
|
||||
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;
|
||||
},
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user