mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: allow set and setInDomain for oauth response
This commit is contained in:
2 files changed
+5
-1
No files matched your search
@@ -271,6 +271,7 @@ class UserRegisterWithCodeHandler extends Handler {
|
||||
if (mailDomain === 'qq.com' && !Number.isNaN(+id)) $set.avatar = `qq:${id}`;
|
||||
if (this.session.viewLang) $set.viewLang = this.session.viewLang;
|
||||
if (Object.keys($set).length) await user.setById(uid, $set);
|
||||
if (Object.keys(this.tdoc.setInDomain || {}).length) await domain.setUserInDomain(domainId, uid, this.tdoc.setInDomain);
|
||||
if (this.tdoc.oauth) await oauth.set(this.tdoc.oauth[1], uid);
|
||||
this.context.HydroContext.user = await user.getById(domainId, uid);
|
||||
this.session.viewLang = '';
|
||||
@@ -456,7 +457,7 @@ class OauthCallbackHandler extends Handler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const set: Partial<Udoc> = { oauth: args.type };
|
||||
const set: Partial<Udoc> = { oauth: args.type, ...r.set };
|
||||
if (r.bio) set.bio = r.bio;
|
||||
if (r.viewLang) set.viewLang = r.viewLang;
|
||||
if (r.avatar) set.avatar = r.avatar;
|
||||
@@ -468,6 +469,7 @@ class OauthCallbackHandler extends Handler {
|
||||
username,
|
||||
redirect: this.domain.registerRedirect,
|
||||
set,
|
||||
setInDomain: r.setInDomain,
|
||||
oauth: [args.type, r._id],
|
||||
},
|
||||
);
|
||||
|
||||
@@ -58,6 +58,8 @@ export interface OAuthUserResponse {
|
||||
bio?: string;
|
||||
uname?: string[];
|
||||
viewLang?: string;
|
||||
set?: Record<string, any>;
|
||||
setInDomain?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface Authenticator {
|
||||
|
||||
Reference in new issue
Block a user