Add Telemetry (#466)
* Telemetry v1 * Add package-lock.json to gitignore
This commit is contained in:
20
server/src/guards/optional-jwt.auth.guard.ts
Normal file
20
server/src/guards/optional-jwt.auth.guard.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { ExecutionContext, Injectable } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { getRequest } from 'src/utils/extract-request';
|
||||
|
||||
@Injectable()
|
||||
export class OptionalJwtAuthGuard extends AuthGuard(['jwt']) {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
getRequest(context: ExecutionContext) {
|
||||
const request = getRequest(context);
|
||||
return request;
|
||||
}
|
||||
|
||||
handleRequest(err, user, info) {
|
||||
if (err || info) return null;
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user