From 616424fab8d8d1ee8939d580c58d2800a9f632e5 Mon Sep 17 00:00:00 2001 From: Khanh Nguyen <119989010+ndkhanh-axonivy@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:36:04 +0700 Subject: [PATCH] MARP-1302 Clear token cookie if user isn't founded (#229) --- .../product-feedback.service.ts | 8 ++++---- .../add-feedback-dialog.component.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-feedbacks-panel/product-feedback.service.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-feedbacks-panel/product-feedback.service.ts index f1b14518b..8867b7062 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-feedbacks-panel/product-feedback.service.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-feedbacks-panel/product-feedback.service.ts @@ -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 { @@ -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); }) ); } @@ -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(); } diff --git a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/add-feedback-dialog/add-feedback-dialog.component.ts b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/add-feedback-dialog/add-feedback-dialog.component.ts index cac1f16e7..c45a910dc 100644 --- a/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/add-feedback-dialog/add-feedback-dialog.component.ts +++ b/marketplace-ui/src/app/modules/product/product-detail/product-detail-feedback/product-star-rating-panel/add-feedback-dialog/add-feedback-dialog.component.ts @@ -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', @@ -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); + } + } }); }