From d2c4a54d3665f324051694fb14b676626042bee7 Mon Sep 17 00:00:00 2001 From: Scott Bishel Date: Mon, 25 Apr 2022 16:11:16 -0600 Subject: [PATCH] GH-2896 - Error on invalid token (#2911) * handle error on invalid token * update message and error to be more generic * fix apostrophe * send user to origin --- webapp/src/errors.ts | 11 +++++++++++ webapp/src/store/initialLoad.ts | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/webapp/src/errors.ts b/webapp/src/errors.ts index a77bfbccd..ba742c424 100644 --- a/webapp/src/errors.ts +++ b/webapp/src/errors.ts @@ -8,6 +8,7 @@ import {UserSettings} from './userSettings' enum ErrorId { TeamUndefined = 'team-undefined', NotLoggedIn = 'not-logged-in', + InvalidReadOnlyBoard = 'invalid-read-only-board', BoardNotFound = 'board-not-found', } @@ -79,6 +80,16 @@ function errorDefFromId(id: ErrorId | null): ErrorDef { errDef.button1Fill = true break } + case ErrorId.InvalidReadOnlyBoard: { + errDef.title = intl.formatMessage({id: 'error.invalid-read-only-board', defaultMessage: 'You don\’t have access to this board. Log in to access Boards.'}) + errDef.button1Enabled = true + errDef.button1Text = intl.formatMessage({id: 'error.go-login', defaultMessage: 'Login'}) + errDef.button1Redirect = (): string => { + return window.location.origin + } + errDef.button1Fill = true + break + } default: { errDef.title = intl.formatMessage({id: 'error.unknown', defaultMessage: 'An error occurred.'}) errDef.button1Enabled = true diff --git a/webapp/src/store/initialLoad.ts b/webapp/src/store/initialLoad.ts index 0e62420fb..d47d19670 100644 --- a/webapp/src/store/initialLoad.ts +++ b/webapp/src/store/initialLoad.ts @@ -48,6 +48,11 @@ export const initialReadOnlyLoad = createAsyncThunk( client.getAllBlocks(boardId), ]) + // if no board, read_token invalid + if (!board) { + throw new Error(ErrorId.InvalidReadOnlyBoard) + } + return {board, blocks} }, )