Skip to content
Snippets Groups Projects
Commit c99c050b authored by Jacopo Gasparetto's avatar Jacopo Gasparetto
Browse files

Fix restore user session not refreshing S3 credentials

Add missing call to observers
parent 6cc6aee4
No related branches found
No related tags found
No related merge requests found
......@@ -143,16 +143,23 @@ export const OAuthProvider = (props: OAuthProviderProps): JSX.Element => {
if (didInit) {
return;
}
const restoredUser: User | undefined = restoreUserSession();
if (restoredUser) {
setOAuthState({
isAuthenticated: (restoredUser.token && !restoredUser.token.expired) ?? false,
isLoading: false,
user: restoredUser
});
didInit = true;
console.log("User's session resumed");
const restoredUser = restoreUserSession();
if (!(restoredUser && restoredUser.token)) {
return;
}
const { token } = restoredUser;
const isAuthenticated = token && !token.expired;
if (isAuthenticated) {
observers.forEach(o => o(token));
}
setOAuthState({
isAuthenticated: isAuthenticated,
isLoading: false,
user: restoredUser
});
didInit = true;
console.log("User's session resumed");
}, []);
// This effect is triggered at each click
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment