in source/web-ui/src/App.tsx [29:56]
async componentDidMount() {
try {
const user = await Auth.currentAuthenticatedUser();
if (user && user.attributes && user.attributes.email) {
this.setState({ email: user.attributes.email });
}
} catch (err) {
console.error(err);
// Reload if the user is no longer authenticated
window.location.reload();
}
// Check the accessToken to see if the user has logged out in another browser tab
// If so, refresh the page so the user is logged out on all tabs
try {
window.addEventListener('storage', (evt) => {
if (evt.storageArea === localStorage && evt.key) {
if (evt.key.startsWith(`CognitoIdentityServiceProvider.${webUIAWSConfig.Auth.userPoolWebClientId}.`) && evt.key.endsWith('.accessToken')) {
if (evt.oldValue && !evt.newValue) {
window.location.reload();
}
}
}
})
} catch (err) {
console.error(err);
}
}