diff --git a/src/components/Api/Api.tsx b/src/components/Api/Api.tsx index 5d2e6dd..91af5ea 100644 --- a/src/components/Api/Api.tsx +++ b/src/components/Api/Api.tsx @@ -92,7 +92,7 @@ export async function TokenRefresh() { "Token refresh success! New Access Token", response.data.access );*/ - return [true, getAccessToken()]; + return [true, JSON.stringify(response.data.access)]; }) .catch((error) => { console.log("Refresh Failed: " + JSON.stringify(error.response.data)); diff --git a/src/components/DrawerSettings/CustomDrawerContent.tsx b/src/components/DrawerSettings/CustomDrawerContent.tsx index 579717b..de521b6 100644 --- a/src/components/DrawerSettings/CustomDrawerContent.tsx +++ b/src/components/DrawerSettings/CustomDrawerContent.tsx @@ -53,7 +53,7 @@ export default function CustomDrawerContent(props: {}) { Register - { navigation.navigate("Revalidation"); @@ -71,6 +71,7 @@ export default function CustomDrawerContent(props: {}) { Activation + */} ); } diff --git a/src/features/redux/slices/AuthSlice/AuthSlice.tsx b/src/features/redux/slices/AuthSlice/AuthSlice.tsx index 39fa0e2..b575579 100644 --- a/src/features/redux/slices/AuthSlice/AuthSlice.tsx +++ b/src/features/redux/slices/AuthSlice/AuthSlice.tsx @@ -8,14 +8,12 @@ export const AuthSlice = createSlice({ uid: "", username: "", full_name: "", - refresh_token: "", - access_token: "", + logged_in: false, }, }, reducers: { - setToken: (state, action) => { - state.creds.access_token = action.payload.access_token; - state.creds.refresh_token = action.payload.refresh_token; + login: (state) => { + state.creds.logged_in = true; }, setUser: (state, action) => { state.creds = { @@ -23,8 +21,7 @@ export const AuthSlice = createSlice({ uid: action.payload.uid, username: action.payload.username, full_name: action.payload.full_name, - access_token: action.payload.access_token, - refresh_token: action.payload.refresh_token, + logged_in: true, }; }, clear: (state) => { @@ -33,14 +30,13 @@ export const AuthSlice = createSlice({ uid: "", username: "", full_name: "", - refresh_token: "", - access_token: "", + logged_in: false, }; }, }, }); // Action creators are generated for each case reducer function -export const { setToken, setUser, clear } = AuthSlice.actions; +export const { login, setUser, clear } = AuthSlice.actions; export default AuthSlice.reducer; diff --git a/src/routes/Login/Login.tsx b/src/routes/Login/Login.tsx index 28c3ef4..2e2873d 100644 --- a/src/routes/Login/Login.tsx +++ b/src/routes/Login/Login.tsx @@ -8,7 +8,6 @@ import { TextInputChangeEventData, } from "react-native"; import { useDispatch } from "react-redux"; -import { setToken } from "../../features/redux/slices/AuthSlice/AuthSlice"; import { colors } from "../../styles"; import { useState } from "react"; import LoginIcon from "../../icons/LoginIcon/LoginIcon"; @@ -87,12 +86,6 @@ export default function Login() { "\nRefresh Token:", result[2] );*/ - dispatch( - setToken({ - access_token: result[1], - refresh_token: result[2], - }) - ); navigation.navigate("Onboarding"); } else { setUser({ diff --git a/src/routes/Revalidation/Revalidation.tsx b/src/routes/Revalidation/Revalidation.tsx index 7117573..622cebf 100644 --- a/src/routes/Revalidation/Revalidation.tsx +++ b/src/routes/Revalidation/Revalidation.tsx @@ -1,7 +1,11 @@ import * as React from "react"; import styles from "../../styles"; import { View, Text, ActivityIndicator } from "react-native"; -import { TokenRefresh, UserInfo } from "../../components/Api/Api"; +import { + TokenRefresh, + UserInfo, + setAccessToken, +} from "../../components/Api/Api"; import { useDispatch } from "react-redux"; import { colors } from "../../styles"; import { useEffect, useState } from "react";