update: route
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
const handleLogOut = () => {
|
||||
localStorage.removeItem('Auth');
|
||||
localStorage.removeItem('session');
|
||||
const handleLogOut = (navigate) => {
|
||||
localStorage.removeItem('Auth');
|
||||
localStorage.removeItem('session');
|
||||
|
||||
if (navigate) {
|
||||
navigate('/signin', { replace: true });
|
||||
} else {
|
||||
window.location.replace('/signin');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default handleLogOut;
|
||||
@@ -8,18 +8,14 @@ const handleSignIn = async (values) => {
|
||||
|
||||
// return false
|
||||
if (response?.status == 200) {
|
||||
/* you can change this according to your authentication protocol */
|
||||
let token = JSON.stringify(response.data?.token);
|
||||
let role = JSON.stringify(response.data?.user?.role_id);
|
||||
|
||||
localStorage.setItem('token', token);
|
||||
response.data.auth = true;
|
||||
localStorage.setItem('session', encryptData(response?.data));
|
||||
if (role === `${import.meta.env.VITE_ROLE_VENDOR}`) {
|
||||
window.location.replace('/dashboard/home-vendor');
|
||||
} else {
|
||||
window.location.replace('/dashboard/home');
|
||||
}
|
||||
|
||||
// langsung redirect ke dashboard utama
|
||||
window.location.replace('/dashboard/home');
|
||||
} else {
|
||||
NotifAlert({
|
||||
icon: 'error',
|
||||
|
||||
Reference in New Issue
Block a user