An open API service indexing awesome lists of open source software.

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.

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);
}

```