mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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
@@ -264,6 +264,19 @@ class UserModel {
|
||||
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 = {}) {
|
||||
return coll.find(params);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user