Skip to content

The open alternative to Salesforce, designed for AI.

fix the bug "require approval" (#9859)

Guillim77c586db24a4
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 43e8f45430d..99a893de275 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 6ce3c33c502..627699c538e 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 10ba1aeca5f..c0ddea4d4b3 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,