fix(server): user can not signup through oauth if ever invited (#6101)

This commit is contained in:
liuyi
2024-03-13 07:50:10 +00:00
parent fd9084ea6a
commit 573528be41
9 changed files with 58 additions and 13 deletions

View File

@@ -153,9 +153,17 @@ export class OAuthController {
if (user) {
// we can't directly connect the external account with given email in sign in scenario for safety concern.
// let user manually connect in account sessions instead.
throw new BadRequestException(
'The account with provided email is not register in the same way.'
);
if (user.registered) {
throw new BadRequestException(
'The account with provided email is not register in the same way.'
);
}
await this.user.fulfillUser(externalAccount.email, {
registered: true,
});
return user;
} else {
user = await this.createUserWithConnectedAccount(
provider,