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:
parent
5efcc4dcac
commit
d2c4a54d36
2 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue