mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: oauth: support lockUsername
This commit is contained in:
2 files changed
+7
-2
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user