Authentication

Materially supports 3 popular Authentication methods.

Materially supports 3 authentication methods: Firebase Authentication, JSON Web Token, Auth0.

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 implemented to make this work the “Guard” concept. It is simply a component that wraps a route and checks for user authentication status before allowing the navigation.

We used two guards GuestGuard and AuthGuard, to find more information about guards, please visit the Routes.ts page.

In the src/layout/App.tsx, we have specified auth provider JWT like,

import { AuthProvider } from 'contexts/AuthContext';

App components wrap with the provider, like

<ThemeProvider theme={theme(customization)}>
  <AuthProvider>  
    <ThemeRoutes />
    <Snackbar />
  </FirebaseProvider>
</AuthProvider>

Using AuthProvider, we can use the context directly by importing useContext from React and specifying the context AuthContext that we want to use, or we can use the custom hook useAuth from src/hooks/useAuth.ts

Auth Configuration:

You can edit this file at [ ../.env]

Switching between Authentication methods

Last updated

Was this helpful?