How it works

MatX uses AuthGuard component to protect auth protected routes. In App.jsx entire application is wrapped by AuthProvider

Here AuthProvider is imported from FirebaseAuthContext. You will find other authProviders for JWT & Auth0 in src/app/contexts/ folder.

As we have wrapped our application by AuthProvider, we can access authenticated user anywhere using useAuth custom hook from src/app/hooks/useAuth.js

How to switch between methods

1. Open App.jsx and update the import path of AuthProvider. By default we're using Firbase. If you want to use JWT method then your import should be like this

2. Open src/app/hooks/useAuth.js and update the import path of AuthContext. By default we are using FirebaseAuthContext. For JWT method, your import should be like this

3. Update session/signin & session/signup in views/sessions/SessionRoutes.js
For example, if you use JWT method use JwtLogin.jsx & JwtRegister.jsx

4. Update firebaseConfig/auth0Config in src/config.js