diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts index 43e8f4543..99a893de2 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/microsoft-apis-auth.controller.ts @@ -77,7 +77,6 @@ export class MicrosoftAPIsAuthController { AuthExceptionCode.FORBIDDEN_EXCEPTION, ); } - if (!workspaceId) { throw new AuthException( 'Workspace not found', @@ -85,6 +84,12 @@ export class MicrosoftAPIsAuthController { ); } + if (emails.length === 0) { + throw new AuthException( + 'No email - Ask your Azure Entra Admin to add you one on top of your User Principal Name', + AuthExceptionCode.USER_NOT_FOUND, + ); + } const handle = emails[0].value; await this.microsoftAPIsService.refreshMicrosoftRefreshToken({ diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts index 6ce3c33c5..627699c53 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts @@ -21,7 +21,7 @@ export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStr options = { ...options, accessType: 'offline', - prompt: 'consent', + prompt: 'select_account', loginHint: req.params.loginHint, state: JSON.stringify({ transientToken: req.params.transientToken, diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/microsoft-apis-oauth-request-code.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/microsoft-apis-oauth-request-code.auth.strategy.ts index 10ba1aeca..c0ddea4d4 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/microsoft-apis-oauth-request-code.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/microsoft-apis-oauth-request-code.auth.strategy.ts @@ -13,7 +13,7 @@ export class MicrosoftAPIsOauthRequestCodeStrategy extends MicrosoftAPIsOauthCom options = { ...options, accessType: 'offline', - prompt: 'consent', + prompt: 'select_account', loginHint: req.params.loginHint, state: JSON.stringify({ transientToken: req.params.transientToken,