|
@@ -109,7 +109,7 @@ export const AuthContextProvider: React.FC = ({children}) => {
|
|
|
|
|
|
if (accessTokenFromStorage) {
|
|
|
try {
|
|
|
- await sendApiRequestAsync({
|
|
|
+ const response = await sendApiRequestAsync({
|
|
|
axiosConfig: {
|
|
|
method: 'GET',
|
|
|
url: '/api/me/',
|
|
@@ -118,12 +118,13 @@ export const AuthContextProvider: React.FC = ({children}) => {
|
|
|
authorized: false,
|
|
|
errorMessage: 'Failed to retrieve user data from server'})
|
|
|
|
|
|
- setAccessToken(accessTokenFromStorage)
|
|
|
- setRefreshToken(await getItemAsync(SECURESTORE_REFRESHTOKEN))
|
|
|
- setNotificationToken(await getItemAsync(SECURESTORE_NOTIFTOKEN))
|
|
|
- setUserId(await getItemAsync(SECURESTORE_ID))
|
|
|
- setAnonUserId('')
|
|
|
- return
|
|
|
+ if (response.status === 200) {
|
|
|
+ setAccessToken(accessTokenFromStorage)
|
|
|
+ setRefreshToken(await getItemAsync(SECURESTORE_REFRESHTOKEN))
|
|
|
+ setNotificationToken(await getItemAsync(SECURESTORE_NOTIFTOKEN))
|
|
|
+ setUserId(await getItemAsync(SECURESTORE_ID))
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
catch {}
|
|
|
}
|
|
@@ -357,8 +358,6 @@ export const AuthContextProvider: React.FC = ({children}) => {
|
|
|
authorized: true,
|
|
|
errorMessage: 'Something went wrong when converting anonymous landmarks'
|
|
|
})
|
|
|
-
|
|
|
- setAnonUserId('')
|
|
|
|
|
|
setAlert({
|
|
|
title: 'Heads up',
|
|
@@ -367,6 +366,8 @@ export const AuthContextProvider: React.FC = ({children}) => {
|
|
|
type: 'warning'
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ setAnonUserId('')
|
|
|
} catch (error) {
|
|
|
reportAxiosError("[Authentication]: Error when checking for anonymous landmarks", error);
|
|
|
setAlert({
|