Authentication
Auth0, JWT, Firebase setup
Berry supports three Authentication methods Firebase, JSON Web Token (JWT), Auth0.
Firebase Authentication set by default
How does it work?
Only authenticated users can access dashboard pages. If a user is not authenticated, the user 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 auth provider FirebaseProvider
like,
App component wrap with the <FirebaseProvider>
Using <FirebaseProvider>
, we can use the context directly by importing useContext
from React and specifying the context FirebaseContext
or we can use the custom hook useAuth
from src/hooks/useAuth.js
Auth Configuration:
You can edit this file at [ ../src/config.js]
Switching between Authentication methods
Firebase to JWT
Set JWT Config
Open file config.js
from directory ..\src\config.js
and set jwt
configuration.
Change Login Form
Open file index.js
at directory ..\src\views\pages\authentication\login\index.js
and use the JWTLogin
component.
Change AuthProvider
Open file App.js
at directory ..\src\App.js
and use JWTProvider
Change auth Hooks
Open file useAuth.js
at directory ..\src\hooks\useAuth.js
and use JWTContext
Firebase to Auth0
Set Auth0 Config
Open file config.js
from directory ..\src\config.js
and set jwt
configuration.
Change Login Form
Open file index.js
at directory ..\src\views\pages\authentication\login\index.js
and use the Auth0Login
component.
Change AuthProvider
Open file App.js
at directory ..\src\App.js
and use Auth0Provider
Change auth Hooks
Open file useAuth.js
at directory ..\src\hooks\useAuth.js
and use Auth0Context
Last updated