Skip to content

Commit 511000e

Browse files
authored
Merge 52a03c9 into cea3a43
2 parents cea3a43 + 52a03c9 commit 511000e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/modules/auth.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,19 @@ export function createAuthModule(
6060
// Build the full redirect URL
6161
const redirectUrl = new URL(fromUrl, window.location.origin).toString();
6262

63-
// Build the provider login URL (google is the default, so no provider path needed)
64-
const providerPath = provider === "google" ? "" : `/${provider}`;
65-
const loginUrl = `${
66-
options.appBaseUrl
67-
}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(
68-
redirectUrl
69-
)}`;
63+
const queryParams = `app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
64+
65+
// SSO uses a different URL structure with appId in the path
66+
let authPath: string;
67+
if (provider === "sso") {
68+
authPath = `/apps/${appId}/auth/sso/login`;
69+
} else {
70+
// Google is the default provider, so no provider path segment needed
71+
const providerPath = provider === "google" ? "" : `/${provider}`;
72+
authPath = `/apps/auth${providerPath}/login`;
73+
}
74+
75+
const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
7076

7177
// Redirect to the provider login page
7278
window.location.href = loginUrl;

src/modules/auth.types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ export interface AuthModule {
199199
* - `'microsoft'` - {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
200200
* - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
201201
* - `'apple'` - {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
202+
* - `'sso'` - Enterprise SSO. Enable SSO in your app's authentication settings before using this provider.
202203
*
203-
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, or `'apple'`.
204+
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
204205
* @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
205206
*
206207
* @example
@@ -220,6 +221,12 @@ export interface AuthModule {
220221
* // Apple
221222
* base44.auth.loginWithProvider('apple', '/dashboard');
222223
* ```
224+
*
225+
* @example
226+
* ```typescript
227+
* // SSO
228+
* base44.auth.loginWithProvider('sso', '/dashboard');
229+
* ```
223230
*/
224231
loginWithProvider(provider: string, fromUrl?: string): void;
225232

0 commit comments

Comments
 (0)