Skip to content

Commit

Permalink
fix: reload the application after an error occurred due to a changed …
Browse files Browse the repository at this point in the history
…pgid
  • Loading branch information
SGrueber committed Jul 12, 2023
1 parent 623921d commit ae10bd4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app/core/configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createPaymentErrorHandler } from './utils/http-error/create-payment.err
import { dataRequestErrorHandler } from './utils/http-error/data-request.error-handler';
import { editPasswordErrorHandler } from './utils/http-error/edit-password.error-handler';
import { LoginUserErrorHandler } from './utils/http-error/login-user.error-handler';
import { pgidChangeErrorHandler } from './utils/http-error/pgid-change.error-handler';
import { requestReminderErrorHandler } from './utils/http-error/request-reminder.error-handler';
import { updateOciConfigurationErrorHandler } from './utils/http-error/update-oci-configuration.error-handler';
import { updatePasswordErrorHandler } from './utils/http-error/update-password.error-handler';
Expand All @@ -18,6 +19,7 @@ import { updatePasswordErrorHandler } from './utils/http-error/update-password.e
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: createPaymentErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: updatePasswordErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: updateOciConfigurationErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: pgidChangeErrorHandler, multi: true },
],
})
export class ConfigurationModule {}
4 changes: 3 additions & 1 deletion src/app/core/utils/api-token/api-token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ export class ApiTokenService {

private isAuthTokenError(err: unknown) {
return (
err instanceof HttpErrorResponse && typeof err.error === 'string' && err.error?.toLowerCase().includes('token')
err instanceof HttpErrorResponse &&
typeof err.error === 'string' &&
(err.error.includes('AuthenticationToken') || err.error.includes('Unable to decode token'))
);
}

Expand Down
11 changes: 11 additions & 0 deletions src/app/core/utils/http-error/pgid-change.error-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SpecialHttpErrorHandler } from 'ish-core/interceptors/icm-error-mapper.interceptor';

// reload page when the pgid of the user has changed
export const pgidChangeErrorHandler: SpecialHttpErrorHandler = {
test: error =>
error.error === 'Bad Request (The provided matrix parameter "pgid" does not match the authenticated user.)',
map: () => {
window.location.reload();
return {};
},
};

0 comments on commit ae10bd4

Please sign in to comment.