Fixed revalidation page not redirecting properly if server is unreachable

This commit is contained in:
Keannu Bernasol 2023-07-06 15:23:01 +08:00
parent 49aa0cb5a6
commit b8efd638ae
2 changed files with 4 additions and 4 deletions

View file

@ -88,11 +88,11 @@ export async function TokenRefresh() {
"Token refresh success! New Access Token", "Token refresh success! New Access Token",
response.data.access response.data.access
);*/ );*/
return [true]; return true;
}) })
.catch((error) => { .catch((error) => {
console.log("Refresh Failed: " + JSON.stringify(error.response.data)); console.log("Refresh Failed: " + JSON.stringify(error.response));
return [false, error.response.data]; return false;
}); });
} }
export async function UserInfo() { export async function UserInfo() {

View file

@ -17,7 +17,7 @@ export default function Revalidation() {
useEffect(() => { useEffect(() => {
setState("Previous session found"); setState("Previous session found");
TokenRefresh().then(async (response) => { TokenRefresh().then(async (response) => {
if (response[0]) { if (response) {
let user_info = await UserInfo(); let user_info = await UserInfo();
await dispatch(setUser(user_info)); await dispatch(setUser(user_info));
if (!(user_info.year_level || user_info.course || user_info.semester)) { if (!(user_info.year_level || user_info.course || user_info.semester)) {