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
9 changed files with 24 additions and 37 deletions
+3 -10
View File
@@ -1,11 +1,4 @@
import {
BadRequestException,
ForbiddenException,
Inject,
Injectable,
Logger,
UnauthorizedException,
} from '@nestjs/common';
import { BadRequestException, ForbiddenException, Inject, Injectable, Logger } from '@nestjs/common';
import { AuthUserDto, ICryptoRepository } from '../auth';
import { IUserRepository, UserCore } from '../user';
import { EditSharedLinkDto } from './dto';
@@ -28,7 +21,7 @@ export class ShareService {
this.userCore = new UserCore(userRepository, cryptoRepository);
}
async validate(key: string): Promise<AuthUserDto> {
async validate(key: string): Promise<AuthUserDto | null> {
const link = await this.shareCore.getByKey(key);
if (link) {
if (!link.expiresAt || new Date(link.expiresAt) > new Date()) {
@@ -47,7 +40,7 @@ export class ShareService {
}
}
}
throw new UnauthorizedException();
return null;
}
async getAll(authUser: AuthUserDto): Promise<SharedLinkResponseDto[]> {