Show login dialog on Flipper startup if user is not logged
Reviewed By: passy Differential Revision: D28780529 fbshipit-source-id: 7f4c38d8461619fe5995654e23dc5739fc852ccc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c1f161045c
commit
48b0eb8f18
@@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
import {Actions} from './';
|
import {Actions} from './';
|
||||||
|
|
||||||
export const USER_UNAUTHORIZED = 'Unauthorized.';
|
|
||||||
export const USER_NOT_SIGNEDIN = 'Not signed in.';
|
|
||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
id?: string;
|
id?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import SignInSheet from '../chrome/fb-stubs/SignInSheet';
|
|||||||
import {errorCounterAtom} from '../chrome/ConsoleLogs';
|
import {errorCounterAtom} from '../chrome/ConsoleLogs';
|
||||||
import {ToplevelProps} from './SandyApp';
|
import {ToplevelProps} from './SandyApp';
|
||||||
import {useValue} from 'flipper-plugin';
|
import {useValue} from 'flipper-plugin';
|
||||||
import {logout, USER_NOT_SIGNEDIN, USER_UNAUTHORIZED} from '../reducers/user';
|
import {logout} from '../reducers/user';
|
||||||
import config from '../fb-stubs/config';
|
import config from '../fb-stubs/config';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
|
import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
|
||||||
@@ -58,6 +58,7 @@ import isProduction from '../utils/isProduction';
|
|||||||
import NetworkGraph from '../chrome/NetworkGraph';
|
import NetworkGraph from '../chrome/NetworkGraph';
|
||||||
import FpsGraph from '../chrome/FpsGraph';
|
import FpsGraph from '../chrome/FpsGraph';
|
||||||
import UpdateIndicator from '../chrome/UpdateIndicator';
|
import UpdateIndicator from '../chrome/UpdateIndicator';
|
||||||
|
import {UserNotSignedInError, UserUnauthorizedError} from '../utils/errors';
|
||||||
|
|
||||||
const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({
|
const LeftRailButtonElem = styled(Button)<{kind?: 'small'}>(({kind}) => ({
|
||||||
width: kind === 'small' ? 32 : 36,
|
width: kind === 'small' ? 32 : 36,
|
||||||
@@ -380,7 +381,10 @@ function LoginButton() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (config.showLogin) {
|
if (config.showLogin) {
|
||||||
getUser().catch((error) => {
|
getUser().catch((error) => {
|
||||||
if (error === USER_UNAUTHORIZED || error === USER_NOT_SIGNEDIN) {
|
if (
|
||||||
|
error instanceof UserUnauthorizedError ||
|
||||||
|
error instanceof UserNotSignedInError
|
||||||
|
) {
|
||||||
setShowLogin(true);
|
setShowLogin(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,6 +17,22 @@ export class CancelledPromiseError extends Error {
|
|||||||
name: 'CancelledPromiseError';
|
name: 'CancelledPromiseError';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UserUnauthorizedError extends Error {
|
||||||
|
constructor(msg: string = 'User unauthorized.') {
|
||||||
|
super(msg);
|
||||||
|
this.name = 'UserUnauthorizedError';
|
||||||
|
}
|
||||||
|
name: 'UserUnauthorizedError';
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UserNotSignedInError extends Error {
|
||||||
|
constructor(msg: string = 'User not signed in.') {
|
||||||
|
super(msg);
|
||||||
|
this.name = 'UserNotSignedInError';
|
||||||
|
}
|
||||||
|
name: 'UserNotSignedInError';
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Error {
|
interface Error {
|
||||||
interaction?: InteractionReport;
|
interaction?: InteractionReport;
|
||||||
|
|||||||
Reference in New Issue
Block a user