1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-11-16 12:20:13 +01:00

fix: max expiration gets ignored if expiration is set to "never"

This commit is contained in:
Elias Schneider 2023-11-17 15:27:22 +01:00
parent 2e1a2b60c4
commit 330eef51e4
No known key found for this signature in database
GPG Key ID: 07E623B294202B6C
4 changed files with 13 additions and 7 deletions

View File

@ -19,7 +19,6 @@ export class ShareOwnerGuard extends JwtGuard {
}
async canActivate(context: ExecutionContext) {
const request: Request = context.switchToHttp().getRequest();
const shareId = Object.prototype.hasOwnProperty.call(
request.params,

View File

@ -54,10 +54,15 @@ export class ShareService {
} else {
const parsedExpiration = parseRelativeDateToAbsolute(share.expiration);
const expiresNever = moment(0).toDate() == parsedExpiration;
if (
this.config.get("share.maxExpiration") !== 0 &&
parsedExpiration >
moment().add(this.config.get("share.maxExpiration"), "hours").toDate()
(expiresNever ||
parsedExpiration >
moment()
.add(this.config.get("share.maxExpiration"), "hours")
.toDate())
) {
throw new BadRequestException(
"Expiration date exceeds maximum expiration date",

View File

@ -12,7 +12,7 @@ const showShareInformationsModal = (
modals: ModalsContextProps,
share: MyShare,
appUrl: string,
maxShareSize: number
maxShareSize: number,
) => {
const t = translateOutsideContext();
const link = `${appUrl}/s/${share.id}`;

View File

@ -125,11 +125,13 @@ const CreateUploadModalBody = ({
"",
) as moment.unitOfTime.DurationConstructor,
);
if (
options.maxExpirationInHours != 0 &&
expirationDate.isAfter(
moment().add(options.maxExpirationInHours, "hours"),
)
(form.values.never_expires ||
expirationDate.isAfter(
moment().add(options.maxExpirationInHours, "hours"),
))
) {
form.setFieldError(
"expiration_num",