Authentication

JWT, Firebase, Auth0, AWS Cognito setup

Berry offers four authentication methods - JSON Web Token (JWT), Firebase, Auth0 and AWS - for users to choose from and can be changed to match the user's needs.

circle-info

JWT Authentication is set by default

How does it work?

Access to dashboard pages is restricted to authenticated users. If a user is not authenticated, they will be redirected to the login page.

We used two guards GuestGuard and AuthGuard. Guards have been configured in src\utils\route-guard\ folder.

In the src/layout/App.js, we have specified the auth provider JWTProvider like,

App.js
import { JWTProvider as AuthProvider } from 'contexts/JWTContext';

App component wrap with the <JWTProvider>

<ThemeCustomization>
  ...
  <AuthProvider>
    <Routes />
    <Snackbar />
  </AuthProvider>
  ...
</<ThemeCustomization>>

Using <JWTProvider>We can use the context directly by importing useContext from React and specifying the context JWTContext Or we can use the custom hook useAuth from src/hooks/useAuth.js

Auth Configuration:

All configurations related to authentication are stored in the .env file. Those configs are like APIKey to connect authentication server, project ID, etc.

triangle-exclamation

The theme provides working an example for Login and Register only. Other flow like reset password, verification have to make it workable by the user himself.

Last updated