Skip to content

The open alternative to Salesforce, designed for AI.

fix(sso|auth): fix sso signinup (#9651)

Antoine Moreaux789ff30dc757
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
index c7accf7cb94..6afa3574443 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
@@ -137,7 +137,7 @@ export class SSOAuthController {
}
private async generateLoginToken(
- user: { email: string } & Record<string, string>,
+ payload: { email: string } & Record<string, string>,
identityProvider: WorkspaceSSOIdentityProvider,
) {
if (!identityProvider) {
@@ -149,16 +149,16 @@ export class SSOAuthController {
const existingUser = await this.userRepository.findOne({
where: {
- email: user.email,
+ email: payload.email,
},
});
const { userData } = this.authService.formatUserDataPayload(
- user,
+ payload,
existingUser,
);
- await this.authService.signInUp({
+ const { workspace, user } = await this.authService.signInUp({
userData,
workspace: identityProvider.workspace,
authParams: {
@@ -170,7 +170,7 @@ export class SSOAuthController {
identityProvider,
loginToken: await this.loginTokenService.generateLoginToken(
user.email,
- identityProvider.workspace.id,
+ workspace.id,
),
};
}