fix(server): auth strategies (#1459)

* fix(server): auth strategies

* chore: tests
This commit is contained in:
Jason Rasmussen 2023-01-28 00:12:11 -05:00 committed by GitHub
parent 5939d79057
commit 414893a687
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 37 deletions

View file

@ -115,10 +115,10 @@ export class AuthService {
}
}
public async validate(headers: IncomingHttpHeaders): Promise<AuthUserDto> {
public async validate(headers: IncomingHttpHeaders): Promise<AuthUserDto | null> {
const tokenValue = this.extractTokenFromHeader(headers);
if (!tokenValue) {
throw new UnauthorizedException('No access token provided in request');
return null;
}
const hashedToken = this.cryptoRepository.hashSha256(tokenValue);
@ -133,7 +133,7 @@ export class AuthService {
};
}
throw new UnauthorizedException('Invalid access token provided');
return null;
}
extractTokenFromHeader(headers: IncomingHttpHeaders) {