mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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('password', Types.Password)
|
||||||
@param('verifyPassword', Types.Password)
|
@param('verifyPassword', Types.Password)
|
||||||
@param('uname', Types.Username)
|
@param('uname', Types.Username, true)
|
||||||
@param('code', Types.String)
|
@param('code', Types.String)
|
||||||
async post(
|
async post(
|
||||||
domainId: string, password: string, verify: string,
|
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 (password !== verify) throw new VerifyPasswordError();
|
||||||
if (this.tdoc.phone) this.tdoc.mail = `${String.random(12)}@hydro.local`;
|
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);
|
const uid = await user.create(this.tdoc.mail, uname, password, undefined, this.request.ip);
|
||||||
|
|||||||
@@ -801,6 +801,7 @@ export interface ModuleInterfaces {
|
|||||||
icon?: string;
|
icon?: string;
|
||||||
get: (this: Handler) => Promise<void>;
|
get: (this: Handler) => Promise<void>;
|
||||||
callback: (this: Handler, args: Record<string, any>) => Promise<OAuthUserResponse>;
|
callback: (this: Handler, args: Record<string, any>) => Promise<OAuthUserResponse>;
|
||||||
|
lockUsername?: boolean;
|
||||||
};
|
};
|
||||||
hash: (password: string, salt: string, user: User) => boolean | string | Promise<string>;
|
hash: (password: string, salt: string, user: User) => boolean | string | Promise<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user