feat(server): user connected accounts migration (#6103)

This commit is contained in:
liuyi
2024-03-13 09:28:52 +00:00
parent fddbb426a6
commit f2ec81b2d0
3 changed files with 62 additions and 1 deletions

View File

@@ -160,8 +160,17 @@ export class OAuthController {
}
await this.user.fulfillUser(externalAccount.email, {
emailVerifiedAt: new Date(),
registered: true,
});
await this.db.connectedAccount.create({
data: {
userId: user.id,
provider,
providerAccountId: externalAccount.id,
...tokens,
},
});
return user;
} else {
@@ -191,7 +200,7 @@ export class OAuthController {
) {
return this.user.createUser({
email: externalAccount.email,
name: 'Unnamed',
name: externalAccount.email.split('@')[0],
avatarUrl: externalAccount.avatarUrl,
emailVerifiedAt: new Date(),
connectedAccounts: {