Skip to content

Commit

Permalink
add token
Browse files Browse the repository at this point in the history
  • Loading branch information
wizhaaa committed Oct 17, 2024
1 parent a490f12 commit c293c9a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions client/src/auth/auth_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ export function useAuthOptionalLogin(): {
useEffect(() => {
const authToken = getAuthToken();
async function getEmail() {
if (authToken && authToken !== '') {
const response = await axios.post('/api/auth/get-email');
if (response.status === 200) {
const email = response.data.result;
setNetId(email.substring(0, email.lastIndexOf('@')));
}
const response = await axios.post('/api/auth/get-email', { token: authToken });
if (response.status === 200) {
const email = response.data.result;
setNetId(email.substring(0, email.lastIndexOf('@')));
}
}

if (authToken && authToken !== '') {
getEmail().catch(e => console.log('[ERROR] Get Email in useAuthOptionalLogin(): ', e));
setToken(authToken)
setIsLoggedIn(true)
}
getEmail().catch(e => console.log('[ERROR] Get Email in useAuthOptionalLogin(): ', e));

}, [])

const signIn = (redirectFrom: string) => {
Expand Down

0 comments on commit c293c9a

Please sign in to comment.