refactor: move guard checks to service

This commit is contained in:
Elias Schneider
2023-01-31 13:53:23 +01:00
parent 233c26e5cf
commit cd9d828686
3 changed files with 16 additions and 19 deletions

View File

@@ -273,8 +273,16 @@ export class ShareService {
if (
share?.security?.password &&
!(await argon.verify(share.security.password, password))
)
) {
throw new ForbiddenException("Wrong password");
}
if (share.security?.maxViews && share.security.maxViews <= share.views) {
throw new ForbiddenException(
"Maximum views exceeded",
"share_max_views_exceeded"
);
}
const token = await this.generateShareToken(shareId);
await this.increaseViewCount(share);