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} }, )