mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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 (mailDomain === 'qq.com' && !Number.isNaN(+id)) $set.avatar = `qq:${id}`;
|
||||||
if (this.session.viewLang) $set.viewLang = this.session.viewLang;
|
if (this.session.viewLang) $set.viewLang = this.session.viewLang;
|
||||||
if (Object.keys($set).length) await user.setById(uid, $set);
|
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);
|
if (this.tdoc.oauth) await oauth.set(this.tdoc.oauth[1], uid);
|
||||||
this.context.HydroContext.user = await user.getById(domainId, uid);
|
this.context.HydroContext.user = await user.getById(domainId, uid);
|
||||||
this.session.viewLang = '';
|
this.session.viewLang = '';
|
||||||
@@ -456,7 +457,7 @@ class OauthCallbackHandler extends Handler {
|
|||||||
break;
|
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.bio) set.bio = r.bio;
|
||||||
if (r.viewLang) set.viewLang = r.viewLang;
|
if (r.viewLang) set.viewLang = r.viewLang;
|
||||||
if (r.avatar) set.avatar = r.avatar;
|
if (r.avatar) set.avatar = r.avatar;
|
||||||
@@ -468,6 +469,7 @@ class OauthCallbackHandler extends Handler {
|
|||||||
username,
|
username,
|
||||||
redirect: this.domain.registerRedirect,
|
redirect: this.domain.registerRedirect,
|
||||||
set,
|
set,
|
||||||
|
setInDomain: r.setInDomain,
|
||||||
oauth: [args.type, r._id],
|
oauth: [args.type, r._id],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ export interface OAuthUserResponse {
|
|||||||
bio?: string;
|
bio?: string;
|
||||||
uname?: string[];
|
uname?: string[];
|
||||||
viewLang?: string;
|
viewLang?: string;
|
||||||
|
set?: Record<string, any>;
|
||||||
|
setInDomain?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Authenticator {
|
export interface Authenticator {
|
||||||
|
|||||||
Reference in new issue
Block a user