Skip to content

Commit

Permalink
MARP-1302 Clear token cookie if user isn't founded (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkhanh-axonivy authored Nov 8, 2024
1 parent c7d0fb0 commit 616424f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
signal,
WritableSignal
} from '@angular/core';
import { catchError, EMPTY, Observable, of, tap } from 'rxjs';
import { catchError, Observable, of, tap, throwError } from 'rxjs';
import { CookieService } from 'ngx-cookie-service';
import { AuthService } from '../../../../../auth/auth.service';
import {
Expand Down Expand Up @@ -77,11 +77,11 @@ export class ProductFeedbackService {
catchError(response => {
if (
response.status === NOT_FOUND_ERROR_CODE &&
response.error.helpCode === USER_NOT_FOUND_ERROR_CODE
response.error.helpCode === USER_NOT_FOUND_ERROR_CODE.toString()
) {
this.clearTokenCookie();
}
return EMPTY;
return throwError(() => response);
})
);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ export class ProductFeedbackService {
catchError(response => {
if (
response.status === NOT_FOUND_ERROR_CODE &&
response.error.helpCode === USER_NOT_FOUND_ERROR_CODE
response.error.helpCode === USER_NOT_FOUND_ERROR_CODE.toString()
) {
this.clearTokenCookie();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { MultilingualismPipe } from '../../../../../../shared/pipes/multilingual
import { AppModalService } from '../../../../../../shared/services/app-modal.service';
import { ProductDetailService } from '../../../product-detail.service';
import { ProductFeedbackService } from '../../product-feedbacks-panel/product-feedback.service';
import { throwError } from 'rxjs';
import { CommonDropdownComponent } from '../../../../../../shared/components/common-dropdown/common-dropdown.component';
import { NOT_FOUND_ERROR_CODE, USER_NOT_FOUND_ERROR_CODE } from '../../../../../../shared/constants/common.constant';

@Component({
selector: 'app-add-feedback-dialog',
Expand Down Expand Up @@ -60,7 +60,14 @@ export class AddFeedbackDialogComponent {
this.activeModal.close();
this.appModalService.openSuccessDialog();
},
error: error => throwError(() => error)
error: error => {
if (
error.status === NOT_FOUND_ERROR_CODE &&
error.error.helpCode === USER_NOT_FOUND_ERROR_CODE.toString()
) {
this.authService.redirectToGitHub(this.feedback.productId);
}
}
});
}

Expand Down

0 comments on commit 616424f

Please sign in to comment.