This document serves as a guide to the various authentication utility functions used in your typical frontend application. Each function is listed with its location in the file and a brief description of its purpose. Use keywords like "sign up", "login", "set cookie", "password", and "roles" to quickly find the relevant functions using "Ctrl + F".
1.1. Configuration
1.2. User Authentication
- getCurrentUser
- refreshToken
- signInWithGoogle
- logInWithEmailAndPassword
- createUserInFirebase
- createUser
- registerWithEmailAndPassword
- sendPasswordReset
- sendInviteLink
- confirmNewPassword
- confirmVerifyEmail
- logout
- EmailAction
1.3. Backend Interactions
2.1. Authentication Utilities
2.2. Protected Route Component
3.1. React-Cookie Integration
3.2. Cookie Management
- Location: Source
- Description: Sets up the Firebase app configuration using environment variables.
- Location: Source
- Description: Returns the current user synchronously.
- Location: Source
- Description: Refreshes the current user's access token by making a request to Firebase.
- Location: Source
- Description: Signs a user in with Google using Firebase. Users are given
USER_ROLE
by default.
- Location: Source
- Description: Logs a user in with email and password, and checks if the email is verified.
- Location: Source
- Description: Creates a user in the Firebase database.
- Location: Source
- Description: Creates a user both in Firebase and the NPO database, then sends an email verification.
- Location: Source
- Description: Registers a new user using email and password, then navigates to the specified path.
- Location: Source
- Description: Sends a password reset email to the specified email address.
- Location: Source
- Description: Sends an invite link to create a new account with a specified email.
- Location: Source
- Description: Completes the password reset process with a confirmation code and new password.
- Location: Source
- Description: Applies a verification code sent to the user by email.
- Location: Source
- Description: Logs a user out and navigates to the specified path.
- Location: Source
- Description: Handles specific email-related actions, such as resetting a password or verifying an email address, based on the query parameters present in the URL.
- Location: Source
- Description: Adds a user to the NPO database and deletes the Firebase user if there's an error.
- Location: Source
- Description: Completes the additional information required for a Google login registration.
- Location: Source
- Description: Adds an Axios interceptor to refresh the user's access token if it expires.
- Location: Source
- Description: An object containing various roles used in the authentication system.
- Location: Source
- Description: Checks if the user is authenticated and has the required role to access a route.
- Location: Source
- Description: Protects a route from unauthenticated users and redirects them if necessary.
- Location: Source
- Description: Higher-order component to provide cookies context to a component.
- Location: Source
- Description: Provides the Cookies API for managing cookies in the application.
- Location: Source
- Description: Options for the format of a cookie, including
maxAge
,path
, andsecure
attributes.
- Location: Source
- Description: An object containing keys for cookies to store, such as
ACCESS_TOKEN
andROLE
.
- Location: Source
- Description: Sets a cookie in the browser with specified configuration.
- Location: Source
- Description: Clears all cookies stored during login by removing each cookie specified in
cookieKeys
.
- Registering New Accounts: Source
- Sending Admin Role Invites: Source
- Handle Forgotten Passwords: Source
- Login: Source
- Logout: Source
- Adding New User to DB: Source
- Reset Password: Source
- Verify Email: Source
This README provides an organized overview of the authentication utilities in our frontend application, facilitating quick access to specific functions based on their keywords and descriptions.