No se puede usar refresh token sin client secret en pkce

Por lo que se almacena el access_token en local storage para persistir
el login del usuario
This commit is contained in:
Daniel Cortes
2020-07-14 08:11:14 -04:00
parent 418a73657d
commit a25a985263
2 changed files with 11 additions and 0 deletions

View File

@@ -7,6 +7,16 @@ import {useStateValue} from "../services/State";
export const AuthMiddleware = () => {
useRouteMatch('*');
const [context, dispatch] = useStateValue();
const user = window.localStorage.getItem('user');
const access_token = window.localStorage.getItem('access_token');
if((!context.user || !context.user.auth) && (user && access_token)){
dispatch({type: 'login', user:{auth: true, access_token: access_token}})
}
return null;
}

View File

@@ -116,6 +116,7 @@ export const auth = async (params) => {
const expires = new Date(new Date().getTime() + ((response.expires_in) * 1000))
window.localStorage.setItem('refresh_token', refresh);
window.localStorage.setItem('access_token', access_token);
window.localStorage.setItem('expires', expires);
// Almacenar el usuario en localStorage