From 04835ce7107aa8103c692c1743c3a190a6e80df9 Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Sun, 14 Sep 2025 17:36:50 +0300 Subject: [PATCH 1/6] Change redirectToLogin to absolute path --- src/modules/auth.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/auth.ts b/src/modules/auth.ts index db10ed0..f0794e4 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -54,7 +54,9 @@ export function createAuthModule( const redirectUrl = nextUrl || window.location.href; // Build the login URL - const loginUrl = `/login?from_url=${encodeURIComponent(redirectUrl)}`; + const loginUrl = `${ + options.serverUrl + }/login?from_url=${encodeURIComponent(redirectUrl)}`; // Redirect to the login page window.location.href = loginUrl; From ae3a42b488c02d90cd8e0496deb1402b7855b9d9 Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Sun, 14 Sep 2025 20:03:19 +0300 Subject: [PATCH 2/6] tests --- src/modules/auth.ts | 2 +- tests/unit/auth.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/auth.ts b/src/modules/auth.ts index f0794e4..3303575 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -56,7 +56,7 @@ export function createAuthModule( // Build the login URL const loginUrl = `${ options.serverUrl - }/login?from_url=${encodeURIComponent(redirectUrl)}`; + }/login?from_url=${encodeURIComponent(redirectUrl)}&app_id=${appId}`; // Redirect to the login page window.location.href = loginUrl; diff --git a/tests/unit/auth.test.js b/tests/unit/auth.test.js index 1e9afbb..e871ceb 100644 --- a/tests/unit/auth.test.js +++ b/tests/unit/auth.test.js @@ -149,7 +149,7 @@ describe('Auth Module', () => { // Verify the redirect URL was set correctly expect(mockLocation.href).toBe( - `/login?from_url=${encodeURIComponent(nextUrl)}` + `${serverUrl}/login?from_url=${encodeURIComponent(nextUrl)}&app_id=${appId}` ); // Restore window @@ -169,7 +169,7 @@ describe('Auth Module', () => { // Verify the redirect URL uses current URL expect(mockLocation.href).toBe( - `/login?from_url=${encodeURIComponent(currentUrl)}` + `${serverUrl}/login?from_url=${encodeURIComponent(currentUrl)}&app_id=${appId}` ); // Restore window From ad38cbd2b4e8626d8d45409d7a7c1edd535cd0fa Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Mon, 15 Sep 2025 14:36:24 +0300 Subject: [PATCH 3/6] add optional headers --- src/client.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client.ts b/src/client.ts index 261367c..3a035f8 100644 --- a/src/client.ts +++ b/src/client.ts @@ -31,6 +31,7 @@ export function createClient(config: { serviceToken?: string; requiresAuth?: boolean; functionsVersion?: string; + headers?: Record; options?: CreateClientOptions; onRedirectToLogin?: () => void; }) { @@ -43,6 +44,7 @@ export function createClient(config: { options, functionsVersion, onRedirectToLogin, + headers: optionalHeaders, } = config; const socketConfig: RoomsSocketConfig = { @@ -58,6 +60,7 @@ export function createClient(config: { }); const headers = { + ...optionalHeaders, "X-App-Id": String(appId), }; From e0b63fe818991444638b0debf57a6e217fee9ae0 Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Mon, 15 Sep 2025 15:32:26 +0300 Subject: [PATCH 4/6] adding missing auth methods --- src/modules/auth.ts | 73 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/modules/auth.ts b/src/modules/auth.ts index 3303575..8c96a6d 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -1,4 +1,5 @@ import { AxiosInstance } from "axios"; +import { RegisterPayload } from "./auth.types"; /** * Creates the auth module for the Base44 SDK @@ -174,5 +175,77 @@ export function createAuthModule( return false; } }, + + inviteUser(userEmail: string, role: string) { + return axios.post(`/apps/${appId}/users/invite-user`, { + user_email: userEmail, + role, + }); + }, + + register(payload: { + email: string; + password: string; + turnstile_token?: string | null; + referral_code?: string | null; + }) { + return axios.post(`/apps/${appId}/auth/register`, payload); + }, + + verifyOtp({ email, otpCode }: { email: string; otpCode: string }) { + return axios.post(`/apps/${appId}/auth/verify-otp`, { + email, + otp_code: otpCode, + }); + }, + + resendOtp(email: string) { + return axios.post(`/apps/${appId}/auth/resend-otp`, { email }); + }, + + loginViaUsernamePassword({ + email, + password, + }: { + email: string; + password: string; + }) { + return axios.post(`/apps/${appId}/auth/login`, { email, password }); + }, + + resetPasswordRequest(email: string) { + return axios.post(`/apps/${appId}/auth/reset-password-request`, { + email, + }); + }, + + resetPassword({ + resetToken, + newPassword, + }: { + resetToken: string; + newPassword: string; + }) { + return axios.post(`/apps/${appId}/auth/reset-password`, { + reset_token: resetToken, + new_password: newPassword, + }); + }, + + changePassword({ + userId, + currentPassword, + newPassword, + }: { + userId: string; + currentPassword: string; + newPassword: string; + }) { + return axios.post(`/apps/${appId}/auth/change-password`, { + user_id: userId, + current_password: currentPassword, + new_password: newPassword, + }); + }, }; } From d6dd060664be954dcfd097068b06948cd07d571b Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Mon, 15 Sep 2025 15:35:41 +0300 Subject: [PATCH 5/6] unused --- src/modules/auth.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/auth.ts b/src/modules/auth.ts index 8c96a6d..98f64d5 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -1,5 +1,4 @@ import { AxiosInstance } from "axios"; -import { RegisterPayload } from "./auth.types"; /** * Creates the auth module for the Base44 SDK From bf9a2307b470089bde873b26f6e1f187d9ff5e00 Mon Sep 17 00:00:00 2001 From: Omer Katzir Date: Mon, 15 Sep 2025 17:14:55 +0300 Subject: [PATCH 6/6] remove dup --- src/modules/auth.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/modules/auth.ts b/src/modules/auth.ts index 98f64d5..651e941 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -202,16 +202,6 @@ export function createAuthModule( return axios.post(`/apps/${appId}/auth/resend-otp`, { email }); }, - loginViaUsernamePassword({ - email, - password, - }: { - email: string; - password: string; - }) { - return axios.post(`/apps/${appId}/auth/login`, { email, password }); - }, - resetPasswordRequest(email: string) { return axios.post(`/apps/${appId}/auth/reset-password-request`, { email,