fix login & fix logout
This commit is contained in:
@@ -132,16 +132,9 @@ function AuthProvider({ children }: AuthProviderProps) {
|
||||
axios
|
||||
.post('/verify-code', { phoneOrEmail: phoneOrEmail, otp })
|
||||
.then((response) => {
|
||||
const { user, token } = response.data.data;
|
||||
const { token } = response.data.data;
|
||||
setSession(token);
|
||||
|
||||
dispatch({
|
||||
type: Types.ValidateOtp,
|
||||
payload: {
|
||||
user,
|
||||
},
|
||||
});
|
||||
|
||||
return response.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -149,9 +142,11 @@ function AuthProvider({ children }: AuthProviderProps) {
|
||||
if (error.response.status !== 422) throw error.response;
|
||||
});
|
||||
|
||||
const logout = async () => {
|
||||
await axios.post('/logout');
|
||||
const logout = () => {
|
||||
setSession(null);
|
||||
localStorage.removeItem('loginOrVerifyCode');
|
||||
localStorage.removeItem('emailOrPhone');
|
||||
localStorage.removeItem('emailOrPhoneForm');
|
||||
dispatch({ type: Types.Logout });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user