• Deactivate user handler

    Parameters

    • userService: UserDataService

      Injected service used to handle the user-related operations.

    • authAPI: Pick<AuthDefaultAdapterAPI, "deleteRefreshTokensForUser">

      Injected authentication API for deleting refresh tokens.

    • deactivateUserEmailConfig: DeactivateUserEmailConfig & {
          mailService?: MailService;
          sender: string;
      }

      Configuration for deactivation email.

    • authDependencies: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
      }

      authSecrets - Auth Secrets authenticate - Authentication function

      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
    • logger: Logger

      Injected logger for logging.

    • context: AdapterHandlerContext

      Request context containing headers, body, params, and query. body.userId is required.

    Returns Promise<adapter.AdapterHandlerResponse>

    204 Status No Content

    Description

    This handler will lock the user by applying the following steps in sequence:

    1. Verify the user exists (userService.getUserById).
    2. Set isLocked for the user (userService.updateUser).
    3. Delete refresh tokens for the user (authAPI.deleteRefreshTokensForUser).

    Throws

    Error - When userId is not defined.

    Throws

    Error - When deactivateUserEmailConfig is not defined.

    Throws

    Error - When no mail service is provided in the configuration.

    Throws

    Error - When the user has no email.

    Throws

    Error - When failed to send the deactivation email.

Generated using TypeDoc