mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-29 01:28:59 -05:00
refactor: manual merge conflict changes that broke that application
This commit is contained in:
parent
9d17377bbc
commit
83cde4778a
1 changed files with 6 additions and 8 deletions
|
@ -5,19 +5,13 @@ import {
|
||||||
Injectable,
|
Injectable,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
import { Reflector } from "@nestjs/core";
|
|
||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import * as moment from "moment";
|
import * as moment from "moment";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { ShareService } from "src/share/share.service";
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ShareTokenSecurity implements CanActivate {
|
export class ShareTokenSecurity implements CanActivate {
|
||||||
constructor(
|
constructor(private prisma: PrismaService) {}
|
||||||
private reflector: Reflector,
|
|
||||||
private shareService: ShareService,
|
|
||||||
private prisma: PrismaService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext) {
|
async canActivate(context: ExecutionContext) {
|
||||||
const request: Request = context.switchToHttp().getRequest();
|
const request: Request = context.switchToHttp().getRequest();
|
||||||
|
@ -33,7 +27,11 @@ export class ShareTokenSecurity implements CanActivate {
|
||||||
include: { security: true },
|
include: { security: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!share || moment().isAfter(share.expiration))
|
if (
|
||||||
|
!share ||
|
||||||
|
(moment().isAfter(share.expiration) &&
|
||||||
|
!moment(share.expiration).isSame(0))
|
||||||
|
)
|
||||||
throw new NotFoundException("Share not found");
|
throw new NotFoundException("Share not found");
|
||||||
|
|
||||||
if (share.security?.maxViews && share.security.maxViews <= share.views)
|
if (share.security?.maxViews && share.security.maxViews <= share.views)
|
||||||
|
|
Loading…
Add table
Reference in a new issue