Mantis MUI React
v1.1.0
v1.1.0
  • Documentation
  • Pre-requisites
  • Quick Start
  • Folder Structure
  • State Management
  • Internationalization
  • Authentication
    • Switch to Auth0
    • Switch to JWT
    • Switch to AWS Cognito
  • Axios API Calls
  • Routing
  • Project Configuration
  • Color Presets
  • Theme/Style Configuration
  • Integration
    • Skeleton
    • Seed
    • Comparison
  • Resources
  • Roadmap
  • Support
  • Changelog
  • FAQ
Powered by GitBook
On this page
  1. Authentication

Switch to JWT

PreviousSwitch to Auth0NextSwitch to AWS Cognito

Last updated 2 years ago

Firebase to JWT

Set JWT Config

At present, jwt uses a dummy backend call, so we don't need any secret, but in actual implementation, you need to set a secret in the following file. For more detail refer to JWT here:

..\src\config.js
...
export const JWT_API = {
  secret: 'SECRET-KEY',
  timeout: '1 days'
};
...

Change AuthProvider

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

Change auth Hooks

Comment another context in the following file and uncomment JWT one.

..\src\hooks\useAuth.js
import AuthContext from 'contexts/JWTContext';

Copy login code

It's also super simple. We have provided a code that just needs to be replaced.

  • From: src\sections\auth\login\JWTLogin

  • To: src\sections\auth\auth-forms\AuthLogin.js

For nextJS, src\components\Authentication\login\JWTLogin to src\components\Authentication\auth-forms\AuthLogin.tsx

Copy register code

We have provided a code that just needs to be replaced.

  • From: src\sections\auth\register\JWTRegister

  • To: src\sections\auth\auth-forms\AuthRegister.js

For nextJS, src\components\Authentication\login\JWTRegister to src\components\Authentication\auth-forms\AuthRegister.tsx

https://jwt.io/introduction