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
This commit is contained in:
Scott Bishel 2022-04-25 16:11:16 -06:00 committed by GitHub
parent 5efcc4dcac
commit d2c4a54d36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -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

View file

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