Authentication module for managing user authentication and authorization. The module automatically stores tokens in local storage when available and manages authorization headers for API requests. This module provides comprehensive authentication functionality including:
- Email/password login and registration
- Token management
- User profile access and updates
- Password reset flows
- OTP verification
- User invitations
base44.auth).
Methods
me()
me():Gets the current authenticated user’s information.Promise<User>
Returns
User
An authenticated user.
Properties
Properties
Unique user identifier.
When the user was created.
When the user was last updated.
User’s email address.
User’s full name.
Whether the user is disabled.
Whether the user’s email has been verified.
The app ID this user belongs to.
Whether this is a service account.
User’s role in the app. Roles are configured in the app settings and determine the user’s permissions and access levels.
Additional custom fields defined in the user schema. Any custom properties added to the user schema in the app will be available here with their configured types and values.
Example
updateMe()
updateMe(Updates the current authenticated user’s information. Only the fields included in the data object will be updated. Commonly updated fields includedata):Promise<User>
full_name and custom profile fields.
Parameters
Object containing the fields to update.
Properties
Properties
Unique user identifier.
When the user was created.
When the user was last updated.
User’s email address.
User’s full name.
Whether the user is disabled.
Whether the user’s email has been verified.
The app ID this user belongs to.
Whether this is a service account.
User’s role in the app. Roles are configured in the app settings and determine the user’s permissions and access levels.
Returns
User
An authenticated user.
Properties
Properties
Unique user identifier.
When the user was created.
When the user was last updated.
User’s email address.
User’s full name.
Whether the user is disabled.
Whether the user’s email has been verified.
The app ID this user belongs to.
Whether this is a service account.
User’s role in the app. Roles are configured in the app settings and determine the user’s permissions and access levels.
Additional custom fields defined in the user schema. Any custom properties added to the user schema in the app will be available here with their configured types and values.
Examples
redirectToLogin()
redirectToLogin(Redirects the user to the app’s login page. Redirects with a callback URL to return to after successful authentication. Requires a browser environment and can’t be used in the backend.nextUrl):void
Parameters
URL to redirect to after successful login.
Returns
void
Throws
When not in a browser environment.Examples
logout()
logout(Logs out the current user. Removes the authentication token from local storage and Axios headers, then optionally redirects to a URL or reloads the page. Requires a browser environment and can’t be used in the backend.redirectUrl?):void
Parameters
Optional URL to redirect to after logout. Reloads the page if not provided.
Returns
void
Examples
setToken()
setToken(Sets the authentication token. Updates the authorization header for API requests and optionally saves the token to local storage for persistence. Saving to local storage requires a browser environment and is automatically skipped in backend environments.token,saveToStorage?):void
Parameters
Properties
Properties
Returns
void
Examples
loginViaEmailPassword()
loginViaEmailPassword(Logs in a registered user using email and password. Authenticates a user with email and password credentials. The user must already have a registered account. For new users, usepassword,turnstileToken?):Promise<LoginResponse>
register() first to create an account. On successful login, automatically sets the token for subsequent requests.
Parameters
Properties
Properties
User’s email address.
User’s password.
Optional Cloudflare Turnstile CAPTCHA token for bot protection.
Returns
LoginResponse
Response from login endpoints containing user information and access token.
Properties
Properties
JWT access token for authentication.
User information.
Properties
Properties
Unique user identifier.
When the user was created.
When the user was last updated.
User’s email address.
User’s full name.
Whether the user is disabled.
Whether the user’s email has been verified.
The app ID this user belongs to.
Whether this is a service account.
User’s role in the app. Roles are configured in the app settings and determine the user’s permissions and access levels.
Examples
isAuthenticated()
isAuthenticated():Checks if the current user is authenticated.Promise<boolean>
Returns
Promise<boolean>
Promise resolving to true if authenticated, false otherwise.
Example
inviteUser()
inviteUser(Invites a user to the app. Sends an invitation email to a potential user with a specific role. Roles are configured in the app settings and determine the user’s permissions and access levels.userEmail,role):Promise<any>
Parameters
Properties
Properties
Returns
Promise<any>
Promise that resolves when the invitation is sent successfully. Throws an error if the invitation fails.
Example
register()
register(Registers a new user account. Creates a new user account with email and password. After successful registration, useparams):Promise<any>
loginViaEmailPassword() to log in the user.
Parameters
Registration details including email, password, and optional fields.
Properties
Properties
Returns
Promise<any>
Promise resolving to the registration response.
Example
verifyOtp()
verifyOtp(Verifies an OTP (One-time password) code. Validates an OTP code sent to the user’s email during registration or authentication.params):Promise<any>
Parameters
Object containing email and OTP code.
Properties
Properties
Returns
Promise<any>
Promise resolving to the verification response if valid.
Throws
Error if the OTP code is invalid, expired, or verification fails.Example
resendOtp()
resendOtp(Resends an OTP code to the user’s email address. Requests a new OTP code to be sent to the specified email address.Promise<any>
Parameters
Email address to send the OTP to.
Returns
Promise<any>
Promise resolving when the OTP is sent successfully.
Throws
Error if the email is invalid or the request fails.Example
resetPasswordRequest()
resetPasswordRequest(Requests a password reset. Sends a password reset email to the specified email address.Promise<any>
Parameters
Email address for the account to reset.
Returns
Promise<any>
Promise resolving when the password reset email is sent successfully.
Throws
Error if the email is invalid or the request fails.Example
resetPassword()
resetPassword(Resets password using a reset token. Completes the password reset flow by setting a new password using the token received by email.params):Promise<any>
Parameters
Object containing the reset token and new password.
Properties
Properties
Returns
Promise<any>
Promise resolving when the password is reset successfully.
Throws
Error if the reset token is invalid, expired, or the request fails.Example
changePassword()
changePassword(Changes the user’s password. Updates the password for an authenticated user by verifying the current password and setting a new one.params):Promise<any>
Parameters
Object containing user ID, current password, and new password.
Properties
Properties
Returns
Promise<any>
Promise resolving when the password is changed successfully.

