faloker/purify

View on GitHub
api/src/auth/ldap-auth.guard.ts

Summary

Maintainability
A
0 mins
Test Coverage
F
50%
/* istanbul ignore file */

import { Injectable, UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';

@Injectable()
export class LdapAuthGuard extends AuthGuard('ldapauth') {
  handleRequest(err, user, info) {
    if (info && !user) {
      throw new UnauthorizedException(info.message);
    }
    return user;
  }
}