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",
|
||||
"version": "2.34.6",
|
||||
"version": "2.34.7",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -58,19 +58,19 @@ export interface Setting {
|
||||
}
|
||||
|
||||
export interface Udoc extends Dictionary<any> {
|
||||
_id: number,
|
||||
mail: string,
|
||||
mailLower: string,
|
||||
uname: string,
|
||||
unameLower: string,
|
||||
salt: string,
|
||||
hash: string,
|
||||
hashType: string,
|
||||
priv: number,
|
||||
regat: Date,
|
||||
loginat: Date,
|
||||
regip: string,
|
||||
loginip: string,
|
||||
_id: number;
|
||||
mail: string;
|
||||
mailLower: string;
|
||||
uname: string;
|
||||
unameLower: string;
|
||||
salt: string;
|
||||
hash: string;
|
||||
hashType: string;
|
||||
priv: number;
|
||||
regat: Date;
|
||||
loginat: Date;
|
||||
ip: string[];
|
||||
loginip: string;
|
||||
}
|
||||
|
||||
export type ownerInfo = { owner: number, maintainer?: number[] };
|
||||
|
||||
@@ -71,7 +71,7 @@ class User implements _User {
|
||||
this._dudoc = dudoc;
|
||||
this._salt = udoc.salt;
|
||||
this._hash = udoc.hash;
|
||||
this._regip = udoc.regip;
|
||||
this._regip = udoc.ip[0];
|
||||
this._loginip = udoc.loginip;
|
||||
this._files = udoc._files || [];
|
||||
|
||||
@@ -147,7 +147,7 @@ class UserModel {
|
||||
priv: 0,
|
||||
regat: 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',
|
||||
};
|
||||
|
||||
@@ -206,6 +206,7 @@ class UserModel {
|
||||
const op: any = {};
|
||||
if ($set && Object.keys($set).length) op.$set = $set;
|
||||
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' });
|
||||
deleteUserCache(res.value);
|
||||
return res;
|
||||
@@ -264,7 +265,7 @@ class UserModel {
|
||||
salt,
|
||||
hashType: 'hydro',
|
||||
regat: new Date(),
|
||||
regip,
|
||||
ip: [regip],
|
||||
loginat: new Date(),
|
||||
loginip: regip,
|
||||
priv,
|
||||
|
||||
@@ -16,7 +16,7 @@ async function _address(
|
||||
if (bset.has(ip)) return;
|
||||
bset.add(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 = [];
|
||||
for (const udoc of users) {
|
||||
tasks.push(_user(udoc._id, bset, uset, dset, dryrun, report));
|
||||
|
||||
@@ -515,6 +515,11 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
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;
|
||||
Reference in new issue
Block a user