Skip to content

Commit

Permalink
fix(front): make sure that auth is available even when the phone is l…
Browse files Browse the repository at this point in the history
…ocked
  • Loading branch information
stdavis committed Nov 2, 2023
1 parent 4ba00c1 commit 59cfd43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"isin",
"isna",
"key",
"keychain",
"knex",
"knexfile",
"levelname",
Expand Down
7 changes: 6 additions & 1 deletion src/front/services/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ export function useSecureState(key) {
return [state, setState];
}

const secureStoreOptions = {
keychainAccessible: SecureStorage.ALWAYS,
};

export function useSecureRef(key) {
const ref = React.useRef();

React.useEffect(() => {
const init = async () => {
const value = await SecureStorage.getItemAsync(key);
const value = await SecureStorage.getItemAsync(key, secureStoreOptions);

try {
ref.current = JSON.parse(value);
Expand All @@ -77,6 +81,7 @@ export function useSecureRef(key) {
SecureStorage.setItemAsync(
key,
typeof value === 'object' ? JSON.stringify(value) : value,
secureStoreOptions,
);
};

Expand Down

0 comments on commit 59cfd43

Please sign in to comment.