How to use the @loopback/rest.HttpErrors.InternalServerError function in @loopback/rest

To help you get started, we’ve selected a few @loopback/rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sourcefuse / loopback4-starter / src / modules / auth / login.controller.ts View on Github external
): Promise {
    if (!this.client || !this.user) {
      throw new HttpErrors.Unauthorized(AuthErrorKeys.ClientInvalid);
    } else if (!this.client.userIds || this.client.userIds.length === 0) {
      throw new HttpErrors.UnprocessableEntity(AuthErrorKeys.ClientUserMissing);
    } else if (!req.client_secret) {
      throw new HttpErrors.BadRequest(AuthErrorKeys.ClientSecretMissing);
    }
    try {
      const payload: ClientAuthCode = {
        clientId: this.client.clientId,
        user: this.user,
      };
      return await this.createJWT(payload, this.client);
    } catch (error) {
      throw new HttpErrors.InternalServerError(
        AuthErrorKeys.InvalidCredentials,
      );
    }
  }
github sourcefuse / loopback4-starter / src / modules / auth / login.controller.ts View on Github external
throw new HttpErrors.Unauthorized(AuthErrorKeys.ClientInvalid);
    }
    try {
      const codePayload: ClientAuthCode = {
        clientId,
        user: this.user,
      };
      const token = jwt.sign(codePayload, client.secret, {
        expiresIn: client.authCodeExpiration,
        audience: clientId,
        subject: this.user.username,
        issuer: process.env.JWT_ISSUER,
      });
      response.redirect(`${client.redirectUrl}?code=${token}`);
    } catch (error) {
      throw new HttpErrors.InternalServerError(AuthErrorKeys.UnknownError);
    }
  }
github sourcefuse / loopback4-starter / src / modules / auth / login.controller.ts View on Github external
try {
      const codePayload: ClientAuthCode = {
        clientId: req.client_id,
        userId: this.user.id,
      };
      const token = jwt.sign(codePayload, this.client.secret, {
        expiresIn: this.client.authCodeExpiration,
        audience: req.client_id,
        subject: req.username,
        issuer: process.env.JWT_ISSUER,
      });
      return {
        code: token,
      };
    } catch (error) {
      throw new HttpErrors.InternalServerError(
        AuthErrorKeys.InvalidCredentials,
      );
    }
  }
github strongloop / loopback-next / labs / authentication-passport / src / strategy-adapter.ts View on Github external
strategy.error = function(error: string) {
        reject(new HttpErrors.InternalServerError(error));
      };
github strongloop / loopback-next / packages / authentication / src / strategy-adapter.ts View on Github external
strategy.error = function(error: string) {
        reject(new HttpErrors.InternalServerError(error));
      };
github strongloop / loopback-next / extensions / authentication-passport / src / strategy-adapter.ts View on Github external
strategy.error = function(error: string) {
        reject(new HttpErrors.InternalServerError(error));
      };