web/satellite: unauthorize error handled
Change-Id: I12c6937ed1660af097d6930fe2a90fac5f298311
This commit is contained in:
parent
13903449c7
commit
6679036ace
@ -66,7 +66,7 @@ func GetAuth(ctx context.Context) (Authorization, error) {
|
||||
}
|
||||
|
||||
if err, ok := value.(error); ok {
|
||||
return Authorization{}, err
|
||||
return Authorization{}, ErrUnauthorized.Wrap(err)
|
||||
}
|
||||
|
||||
return Authorization{}, ErrUnauthorized.New(unauthorizedErrMsg)
|
||||
|
@ -118,6 +118,10 @@ export class AuthHttpApi {
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
if (response.status === 401) {
|
||||
throw new ErrorUnauthorized();
|
||||
}
|
||||
|
||||
throw new Error('can not get user data');
|
||||
}
|
||||
|
||||
|
@ -73,9 +73,12 @@ export default class DashboardArea extends Vue {
|
||||
try {
|
||||
await this.$store.dispatch(USER_ACTIONS.GET);
|
||||
} catch (error) {
|
||||
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.ERROR);
|
||||
await this.$notify.error(error.message);
|
||||
await this.$router.push(RouteConfig.Login.path);
|
||||
if (!(error instanceof ErrorUnauthorized)) {
|
||||
await this.$store.dispatch(APP_STATE_ACTIONS.CHANGE_STATE, AppState.ERROR);
|
||||
await this.$notify.error(error.message);
|
||||
}
|
||||
|
||||
setTimeout(async () => await this.$router.push(RouteConfig.Login.path), 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -87,12 +90,6 @@ export default class DashboardArea extends Vue {
|
||||
await this.$store.dispatch(GET_BILLING_HISTORY);
|
||||
await this.$store.dispatch(GET_PROJECT_CHARGES);
|
||||
} catch (error) {
|
||||
if (error instanceof ErrorUnauthorized) {
|
||||
await this.$router.push(RouteConfig.Login.path);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await this.$notify.error(error.message);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user