web/satellite: unauthorize error handled

Change-Id: I12c6937ed1660af097d6930fe2a90fac5f298311
This commit is contained in:
NikolaiYurchenko 2020-02-03 18:55:44 +02:00 committed by Nikolay Yurchenko
parent 13903449c7
commit 6679036ace
3 changed files with 11 additions and 10 deletions

View File

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

View File

@ -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');
}

View File

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