Skip to content

Commit

Permalink
Applied prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
koss-service committed Dec 16, 2023
1 parent 8e1dd6a commit ae34d46
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
48 changes: 25 additions & 23 deletions src/util/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const DEFAULT_AUTH_CONTEXT: IAuthContext = {
formLink: ROUTER_PATHS.STUDENT_FORM,
dashboardLink: ROUTER_PATHS.STUDENT_DASHBOARD,
jwt: DEFAULT_AUTH_OBJ.jwt,
setUserType: () => { },
updateUserData: () => { },
onLogin: () => { },
onRegister: () => { },
onLogout: () => { },
setUserType: () => {},
updateUserData: () => {},
onLogin: () => {},
onRegister: () => {},
onLogout: () => {},
};

const getLsAuthObj = () => {
Expand Down Expand Up @@ -154,7 +154,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
const updateAuth = (auth: ILocalStorageAuthObj) => {
setUserAuth(auth);

console.log(auth)
console.log(auth);
setFormLink(
userAuth.userData.type === "student"
? ROUTER_PATHS.STUDENT_FORM
Expand Down Expand Up @@ -197,27 +197,29 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
// Load the profile once
useEffect(() => {
if (isAuthenticated) {
makeRequest(
'profile',
'get',
null,
userAuth.jwt
).then(({ response, is_ok }) => {
if (is_ok) {
onRegister({ username: response.username, name: response.name, email: response.email, college: userAuth.userData.college, type: response.type });
} else {
if (response.status_code === 400) {
setIsRegistered(false);
makeRequest("profile", "get", null, userAuth.jwt)
.then(({ response, is_ok }) => {
if (is_ok) {
onRegister({
username: response.username,
name: response.name,
email: response.email,
college: userAuth.userData.college,
type: response.type,
});
} else {
onLogout();
if (response.status_code === 400) {
setIsRegistered(false);
} else {
onLogout();
}
}
}
})
.catch((err) => {
console.log('Error fetching profile from the backend: ', err);
})
.catch((err) => {
console.log("Error fetching profile from the backend: ", err);
});
}
}, [])
}, []);

useEffect(() => {
localStorage.setItem("auth", JSON.stringify(userAuth));
Expand Down
4 changes: 2 additions & 2 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface IEndpointTypes {
username: string;
email: string;
type: UserType;
}
},
};
};
"student/form": {
request: {
username: string;
Expand Down

0 comments on commit ae34d46

Please sign in to comment.