Fix Authentication

This commit is contained in:
2022-05-26 11:38:45 +07:00
parent d2ebf09e48
commit 12c298b9a0
4 changed files with 24 additions and 16 deletions

View File

@@ -87,7 +87,8 @@ function AuthProvider({ children }: AuthProviderProps) {
console.log('initialize', state)
try {
const accessToken = getSession();
console.log('')
if (accessToken) {
setSession(accessToken);
@@ -111,7 +112,6 @@ function AuthProvider({ children }: AuthProviderProps) {
});
}
} catch (err) {
console.error(err);
dispatch({
type: Types.Initial,
payload: {
@@ -124,7 +124,6 @@ function AuthProvider({ children }: AuthProviderProps) {
initialize();
}, []);
// const csrf = () => axios.get('/sanctum/csrf-cookie')
const login = async (email: string, password: string) => {
return axios
@@ -169,8 +168,7 @@ function AuthProvider({ children }: AuthProviderProps) {
dispatch({ type: Types.Logout });
};
return (
<AuthContext.Provider
return (<AuthContext.Provider
value={{
...state,
method: 'jwt',