File

src/lib/fs/caas/caas-unauthorized.handler.ts

Description

This HTTP handler manages unauthorized errors (401) and catches CaaS unauthorized errors by displaying an error message.

Extends

CaasForbiddenHandler

Index

Properties
Methods

Constructor

constructor(fsSpartacusBridgeConfig: FsSpartacusBridgeConfig, tppStatusService: TppStatusService, baseSiteService: BaseSiteService, globalMessageService: GlobalMessageService)

This class creates an instance of a CaasUnauthorizedHandler.

Parameters :
Name Type Optional Description
fsSpartacusBridgeConfig FsSpartacusBridgeConfig No

The Spartacus bridge configuration to use.

tppStatusService TppStatusService No

The TPP status service to use.

baseSiteService BaseSiteService No

The base site service to use.

globalMessageService GlobalMessageService No

The global message service to use.

Methods

getPriority
getPriority()
Inherited from CaasForbiddenHandler

This method returns the priority of this handler. Priority is NORMAL.

Returns : Priority

The priority of this handler, which is NORMAL.

Private handleCaasError
handleCaasError(previewMode: boolean)
Inherited from CaasForbiddenHandler
Parameters :
Name Type Optional
previewMode boolean No
Returns : void
handleError
handleError(request: HttpRequest, errorResponse: HttpErrorResponse)
Inherited from CaasForbiddenHandler

This method handles an error by displaying an error message. If the error is related to the CaaS a specific message is shown.

Parameters :
Name Type Optional Description
request HttpRequest<any> No

The request which leads to the error.

errorResponse HttpErrorResponse No

The received error response.

Returns : void
Private handleNonCaasError
handleNonCaasError()
Inherited from CaasForbiddenHandler
Returns : void
Private isCaasRequest
isCaasRequest(request: HttpRequest)
Inherited from CaasForbiddenHandler
Parameters :
Name Type Optional
request HttpRequest<any> No
Returns : any

Properties

errorMessageKey
Type : string
Default value : 'unauthorized'
Inherited from CaasForbiddenHandler
responseStatus
Type : number
Default value : 401
Inherited from CaasForbiddenHandler
import { TppStatusService } from '../cms/page/tpp-status-service';
import { Injectable } from '@angular/core';
import { BaseSiteService, GlobalMessageService, Priority } from '@spartacus/core';
import { CaasForbiddenHandler } from './caas-forbidden.handler';
import { FsSpartacusBridgeConfig } from 'fs-spartacus-common';

/**
 * This HTTP handler manages unauthorized errors (401) and catches CaaS unauthorized errors by displaying an error message.
 *
 * @export
 * @class CaasUnauthorizedHandler
 * @extends {CaasForbiddenHandler}
 */
@Injectable({
  providedIn: 'root',
})
export class CaasUnauthorizedHandler extends CaasForbiddenHandler {
  responseStatus = 401;
  errorMessageKey = 'unauthorized';

  /**
   * This class creates an instance of a CaasUnauthorizedHandler.
   *
   * @param {FsSpartacusBridgeConfig} fsSpartacusBridgeConfig The Spartacus bridge configuration to use.
   * @param {TppStatusService} tppStatusService The TPP status service to use.
   * @param {BaseSiteService} baseSiteService The base site service to use.
   * @param {GlobalMessageService} globalMessageService The global message service to use.
   * @memberof CaasUnauthorizedHandler
   */
  constructor(
    fsSpartacusBridgeConfig: FsSpartacusBridgeConfig,
    tppStatusService: TppStatusService,
    baseSiteService: BaseSiteService,
    globalMessageService: GlobalMessageService
  ) {
    super(fsSpartacusBridgeConfig, tppStatusService, baseSiteService, globalMessageService);
  }

  /**
   * This method returns the priority of this handler.
   * Priority is NORMAL.
   *
   * @return {Priority} The priority of this handler, which is NORMAL.
   * @memberof CaasUnauthorizedHandler
   */
  getPriority(): Priority {
    return Priority.NORMAL;
  }
}

results matching ""

    No results matching ""