Log users out if tokens have expired, force FB users to login on startup

Summary:
Currently there are several issues caused by internal users not being logged in. E.g. the rating button doesn't work, flipper traces can't be uploaded etc.

However, the fact that the user is not logged in, is not reflected in the UI if the user has an API key, which is outdated.

See also the scuba query in the linked tasks; this happens for quite some users.

This diff fixes two things:
1. If auth tokens are invalid, this is properly reflected in the UI
2. If at startup the profile can't be loaded, a popup will be shown to log in.

Differential Revision: D19392735

fbshipit-source-id: 2be7c577ead671df16c626c0636e89245cebab14
This commit is contained in:
Michel Weststrate
2020-01-15 04:32:45 -08:00
committed by Facebook Github Bot
parent f6831e837a
commit 03c1bcad11
3 changed files with 24 additions and 5 deletions

View File

@@ -9,7 +9,7 @@
import {Store} from '../reducers/index';
import {Logger} from '../fb-interfaces/Logger';
import {login} from '../reducers/user';
import {login, logout} from '../reducers/user';
import {getUser, logoutUser} from '../fb-stubs/user';
export default (store: Store, logger: Logger) => {
@@ -17,7 +17,10 @@ export default (store: Store, logger: Logger) => {
.then(user => {
store.dispatch(login(user));
})
.catch(console.debug);
.catch(e => {
store.dispatch(logout());
console.error(e);
});
let prevUserName = store.getState().user.name;
store.subscribe(() => {