forked from cemaden-educacao/WPD-MobileApp
GabrielTrettel
4 years ago
7 changed files with 89 additions and 29 deletions
-
31src/App.js
-
6src/app/api/auth.js
-
30src/app/auth/context.js
-
29src/app/auth/storage.js
-
10src/app/screens/AccountScreen.js
-
10src/app/screens/LoginScreen.js
-
2src/package.json
@ -0,0 +1,29 @@ |
|||||
|
import * as SecureStore from "expo-secure-store"; |
||||
|
|
||||
|
const key = "authToke"; |
||||
|
|
||||
|
const setToken = async (authToken) => { |
||||
|
try { |
||||
|
await SecureStore.setItemAsync(key, authToken); |
||||
|
} catch (error) { |
||||
|
console.log("Error while storing authToken"); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const getToken = async () => { |
||||
|
try { |
||||
|
return await SecureStore.getItemAsync(key); |
||||
|
} catch (error) { |
||||
|
console.log("Error while gettig authToken"); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const removeToken = async () => { |
||||
|
try { |
||||
|
await SecureStore.deleteItemAsync(key); |
||||
|
} catch (e) { |
||||
|
console.log("Error while removing authToken"); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
export default { setToken, getToken, removeToken }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue