core: allow set and setInDomain for oauth response

This commit is contained in:
undefined committed 2024-10-11 21:52:37 +08:00
1 parent aada95cf12
commit 6557e68c6f
2 files changed
+5 -1

No files matched your search

+3 -1
View File
@@ -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],
},
);
+2
View File
@@ -58,6 +58,8 @@ export interface OAuthUserResponse {
bio?: string;
uname?: string[];
viewLang?: string;
set?: Record<string, any>;
setInDomain?: Record<string, any>;
}
export interface Authenticator {