core: oauth: support lockUsername

This commit is contained in:
undefined committed 2024-09-09 14:12:25 +08:00
1 parent 80ce46a65f
commit cc331e75f3
2 files changed
+7 -2

No files matched your search

+6 -2
View File
@@ -247,12 +247,16 @@ class UserRegisterWithCodeHandler extends Handler {
@param('password', Types.Password)
@param('verifyPassword', Types.Password)
@param('uname', Types.Username)
@param('uname', Types.Username, true)
@param('code', Types.String)
async post(
domainId: string, password: string, verify: string,
uname: string, code: string,
uname = '', code: string,
) {
if (this.tdoc.oauth?.[0] && global.Hydro.module.oauth[this.tdoc.oauth[0]].lockUsername) {
uname = this.tdoc.username;
}
if (!Types.Username[1](uname)) throw new ValidationError('uname');
if (password !== verify) throw new VerifyPasswordError();
if (this.tdoc.phone) this.tdoc.mail = `${String.random(12)}@hydro.local`;
const uid = await user.create(this.tdoc.mail, uname, password, undefined, this.request.ip);
+1
View File
@@ -801,6 +801,7 @@ export interface ModuleInterfaces {
icon?: string;
get: (this: Handler) => Promise<void>;
callback: (this: Handler, args: Record<string, any>) => Promise<OAuthUserResponse>;
lockUsername?: boolean;
};
hash: (password: string, salt: string, user: User) => boolean | string | Promise<string>;
}