cdmoss 2 jaren geleden
bovenliggende
commit
a21b27df01
2 gewijzigde bestanden met toevoegingen van 11 en 10 verwijderingen
  1. 10 9
      src/data/Auth/AuthContext.tsx
  2. 1 1
      src/utils/RequestUtils.ts

+ 10 - 9
src/data/Auth/AuthContext.tsx

@@ -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({

+ 1 - 1
src/utils/RequestUtils.ts

@@ -28,6 +28,6 @@ import Config from 'react-native-config'
 // export const API_URL = 'https://staging.clicknpush.ca'
 
 // export const API_URL = 'http://192.168.3.162:8000'   // Chase
-export const API_URL = 'http://192.168.3.102:8000'       // Eric
+export const API_URL = 'https://app.clicknpush.ca'       // Eric
 
 // export const API_URL = Config.API_URL