feat: update login feature

This commit is contained in:
hanif salafi 2025-07-18 15:24:36 +07:00
parent 1ef498179c
commit 38c5b513ff
2 changed files with 97 additions and 111 deletions

View File

@ -148,19 +148,6 @@ const LoginForm = () => {
const profile = await getProfile(access_token); const profile = await getProfile(access_token);
console.log("PROFILE : ", profile?.data?.data); console.log("PROFILE : ", profile?.data?.data);
if (
profile?.data?.data?.isInternational == true ||
profile?.data?.data?.isActive == false ||
profile?.data?.data?.isDelete == true
) {
Object.keys(Cookies.get()).forEach((cookieName) => {
Cookies.remove(cookieName);
});
warning(
"Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri",
"/auth/login"
);
} else {
Cookies.set("home_path", profile?.data?.data?.homePath, { Cookies.set("home_path", profile?.data?.data?.homePath, {
expires: 1, expires: 1,
}); });
@ -261,7 +248,6 @@ const LoginForm = () => {
}); });
} }
} }
}
} catch (err: any) { } catch (err: any) {
toast.error(err.message || "An unexpected error occurred."); toast.error(err.message || "An unexpected error occurred.");
} }

View File

@ -105,14 +105,14 @@ export const useAuth = (): AuthContextType => {
} }
// Validate user eligibility // Validate user eligibility
if (!isUserEligible(profile)) { // if (!isUserEligible(profile)) {
clearAllCookies(); // clearAllCookies();
warning( // warning(
"Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri", // "Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri",
"/auth" // "/auth"
); // );
return; // return;
} // }
// Set profile cookies // Set profile cookies
setProfileCookies(profile); setProfileCookies(profile);