Skip to content

Authentication

Overview

The Authentication module is designed to facilitate secure user authentication in your application. It provides a comprehensive set of features to manage user accounts, passwords, and session management. Additionally, it includes assets, components/pages used in authentication routes, common interfaces, and supports multiple providers such as Firebase, Supabase, and REST.

Key Features of Authentication Module

  • User Registration: Allows users to create new accounts.
  • User Login: Enables users to log in to their accounts.
  • Login with OTP: Enables users to log in to their accounts with OTP.
  • Forgot Password: Allows users to reset their passwords.
  • Password Reset: Allows users to reset their passwords.
  • 3rd Party Signup: Supports signup using third-party services such as Google Auth.
  • Email Verification: Sends email verification to users.

Module Composition

  • Assets: Includes necessary assets for authentication.
  • Components/Pages: Provides components and pages used in authentication routes.
  • Common Interfaces: Defines common interfaces for authentication.
  • Multiple Providers: Supports Firebase, Supabase, and REST for authentication.
  • Auth Hook: Provides a hook for authentication.
  • React Context Provider: Provides a React context provider for the authentication hook.

Auth Providers

  • Firebase: Provides authentication using Firebase.
  • Supabase: Provides authentication using Supabase.
  • REST: Provides authentication using REST.

Auth Functions

  • signUpWithEmailPassword: Creates a new user account using email and password credentials.
  • signInWithEmailPassword: Authenticates an existing user using their email and password.
  • signInWithOTP: Authenticates an existing user using their email and OTP.
  • signOut: Terminates the current user’s session and logs them out.
  • resetPassword: Initiates the password reset process by sending a link to the user’s email.
  • getSession: Fetches the details of the current user session.
  • setSession: Stores the current session details in the application’s state management system.
  • updateUser: Modifies user information such as email address or password.
  • signInWithIdToken: Authenticates a user using a third-party identity token.

Auth Hook

The Auth Hook is a custom hook that provides a hook for authentication. It is defined in auth/hooks/useAuth.ts.

The useAuth hook returns an object with the following properties:

  • isLoading: A boolean indicating whether the authentication state is currently being determined.
  • session: An object containing the current user’s session information, or null if no user is authenticated.
  • error: An error object if an authentication error occurred, or null if no error.

Auth Context Provider

The Auth Context Provider is a React context provider that provides a React context for the authentication hook. It is defined in auth/contexts/SessionContext.tsx.