https://github.com/this-is-pawan/authentication-user-mern-
FULL STACK MERN AUTHENTICATION PROECT ALL FEATURES ARE AVALIABLE like OTP by email , resetpassword by OTP etc.
https://github.com/this-is-pawan/authentication-user-mern-
contextapi vite
Last synced: 2 months ago
JSON representation
FULL STACK MERN AUTHENTICATION PROECT ALL FEATURES ARE AVALIABLE like OTP by email , resetpassword by OTP etc.
- Host: GitHub
- URL: https://github.com/this-is-pawan/authentication-user-mern-
- Owner: This-is-pawan
- Created: 2025-05-28T10:12:01.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-07T09:21:34.000Z (about 1 year ago)
- Last Synced: 2025-07-13T13:45:13.587Z (about 1 year ago)
- Topics: contextapi, vite
- Language: JavaScript
- Homepage: https://authentication-frontend-flax.vercel.app
- Size: 299 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
both are use
```js
axios.interceptors.response.use(
response => response,
error => {
if (error.response && error.response.status === 401) {
// Token is invalid or expired
localStorage.removeItem('token');
toast.error('Session expired. Please log in again.');
window.location.href = '/login'; // or use navigate('/login') in React Router
}
return Promise.reject(error);
}
);
```
```js
import jwtDecode from 'jwt-decode';
const token = localStorage.getItem('token');
if (token) {
const { exp } = jwtDecode(token);
const expirationTime = exp * 1000 - Date.now();
setTimeout(() => {
localStorage.removeItem('token');
toast.info('Session expired. Please log in again.');
window.location.href = '/login';
}, expirationTime);
}
```