mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: change regip to ip
This commit is contained in:
1 parent
fae452cc94
commit
49a6165472
5 files changed
+24
-18
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.34.6",
|
"version": "2.34.7",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -58,19 +58,19 @@ export interface Setting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Udoc extends Dictionary<any> {
|
export interface Udoc extends Dictionary<any> {
|
||||||
_id: number,
|
_id: number;
|
||||||
mail: string,
|
mail: string;
|
||||||
mailLower: string,
|
mailLower: string;
|
||||||
uname: string,
|
uname: string;
|
||||||
unameLower: string,
|
unameLower: string;
|
||||||
salt: string,
|
salt: string;
|
||||||
hash: string,
|
hash: string;
|
||||||
hashType: string,
|
hashType: string;
|
||||||
priv: number,
|
priv: number;
|
||||||
regat: Date,
|
regat: Date;
|
||||||
loginat: Date,
|
loginat: Date;
|
||||||
regip: string,
|
ip: string[];
|
||||||
loginip: string,
|
loginip: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ownerInfo = { owner: number, maintainer?: number[] };
|
export type ownerInfo = { owner: number, maintainer?: number[] };
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class User implements _User {
|
|||||||
this._dudoc = dudoc;
|
this._dudoc = dudoc;
|
||||||
this._salt = udoc.salt;
|
this._salt = udoc.salt;
|
||||||
this._hash = udoc.hash;
|
this._hash = udoc.hash;
|
||||||
this._regip = udoc.regip;
|
this._regip = udoc.ip[0];
|
||||||
this._loginip = udoc.loginip;
|
this._loginip = udoc.loginip;
|
||||||
this._files = udoc._files || [];
|
this._files = udoc._files || [];
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ class UserModel {
|
|||||||
priv: 0,
|
priv: 0,
|
||||||
regat: new Date('2000-01-01'),
|
regat: new Date('2000-01-01'),
|
||||||
loginat: new Date('2000-01-01'),
|
loginat: new Date('2000-01-01'),
|
||||||
regip: '127.0.0.1',
|
ip: ['127.0.0.1'],
|
||||||
loginip: '127.0.0.1',
|
loginip: '127.0.0.1',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,6 +206,7 @@ class UserModel {
|
|||||||
const op: any = {};
|
const op: any = {};
|
||||||
if ($set && Object.keys($set).length) op.$set = $set;
|
if ($set && Object.keys($set).length) op.$set = $set;
|
||||||
if ($unset && Object.keys($unset).length) op.$unset = $unset;
|
if ($unset && Object.keys($unset).length) op.$unset = $unset;
|
||||||
|
if (op.$set?.loginIp) op.$addToSet = { ip: op.$set.loginIp };
|
||||||
const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnDocument: 'after' });
|
const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnDocument: 'after' });
|
||||||
deleteUserCache(res.value);
|
deleteUserCache(res.value);
|
||||||
return res;
|
return res;
|
||||||
@@ -264,7 +265,7 @@ class UserModel {
|
|||||||
salt,
|
salt,
|
||||||
hashType: 'hydro',
|
hashType: 'hydro',
|
||||||
regat: new Date(),
|
regat: new Date(),
|
||||||
regip,
|
ip: [regip],
|
||||||
loginat: new Date(),
|
loginat: new Date(),
|
||||||
loginip: regip,
|
loginip: regip,
|
||||||
priv,
|
priv,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ async function _address(
|
|||||||
if (bset.has(ip)) return;
|
if (bset.has(ip)) return;
|
||||||
bset.add(ip);
|
bset.add(ip);
|
||||||
report({ message: `ip ${ip}` });
|
report({ message: `ip ${ip}` });
|
||||||
const users = await db.collection('user').find({ $or: [{ loginip: ip }, { regip: ip }] }).toArray();
|
const users = await db.collection('user').find({ ip }).toArray();
|
||||||
const tasks = [];
|
const tasks = [];
|
||||||
for (const udoc of users) {
|
for (const udoc of users) {
|
||||||
tasks.push(_user(udoc._id, bset, uset, dset, dryrun, report));
|
tasks.push(_user(udoc._id, bset, uset, dset, dryrun, report));
|
||||||
|
|||||||
@@ -515,6 +515,11 @@ const scripts: UpgradeScript[] = [
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
async function _44_45() {
|
||||||
|
const _FRESH_INSTALL_IGNORE = 1;
|
||||||
|
await iterateAllUser((udoc) => user.setById(udoc._id, { ip: [udoc.regip] }, { regip: '' }));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
Reference in new issue
Block a user