mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: allow username change
This commit is contained in:
1 parent
70abfd2595
commit
c5f9f86dd7
2 files changed
+14
-1
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.29.18",
|
"version": "2.29.19",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -264,6 +264,19 @@ class UserModel {
|
|||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ArgMethod
|
||||||
|
static async changeUsername(uid: number, uname: string) {
|
||||||
|
const udoc = await coll.findOne({ _id: uid });
|
||||||
|
deleteUserCache(udoc);
|
||||||
|
const res = await coll.findOneAndUpdate(
|
||||||
|
{ _id: uid },
|
||||||
|
{ $set: { uname, unameLower: uname.trim().toLowerCase() } },
|
||||||
|
{ returnDocument: 'after' },
|
||||||
|
);
|
||||||
|
deleteUserCache(res.value);
|
||||||
|
return res.value;
|
||||||
|
}
|
||||||
|
|
||||||
static getMulti(params: any = {}) {
|
static getMulti(params: any = {}) {
|
||||||
return coll.find(params);
|
return coll.find(params);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user