File size: 628 Bytes
7b850b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

import { Injectable, UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { AuthService } from './auth.service';

@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {
    handleRequest(err, user, info) {
        // console.log( user, err, info )
        // You can throw an exception based on either "info" or "err" arguments
        // console.log(user, info, '##################JWT');
        if (err || !user) {
          // console.log('ERROR', err);
          throw err || new UnauthorizedException();
        }
        return user;
      }
}