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:
parent
2e1a2b60c4
commit
330eef51e4
@ -19,7 +19,6 @@ export class ShareOwnerGuard extends JwtGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext) {
|
async canActivate(context: ExecutionContext) {
|
||||||
|
|
||||||
const request: Request = context.switchToHttp().getRequest();
|
const request: Request = context.switchToHttp().getRequest();
|
||||||
const shareId = Object.prototype.hasOwnProperty.call(
|
const shareId = Object.prototype.hasOwnProperty.call(
|
||||||
request.params,
|
request.params,
|
||||||
|
@ -54,10 +54,15 @@ export class ShareService {
|
|||||||
} else {
|
} else {
|
||||||
const parsedExpiration = parseRelativeDateToAbsolute(share.expiration);
|
const parsedExpiration = parseRelativeDateToAbsolute(share.expiration);
|
||||||
|
|
||||||
|
const expiresNever = moment(0).toDate() == parsedExpiration;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.config.get("share.maxExpiration") !== 0 &&
|
this.config.get("share.maxExpiration") !== 0 &&
|
||||||
|
(expiresNever ||
|
||||||
parsedExpiration >
|
parsedExpiration >
|
||||||
moment().add(this.config.get("share.maxExpiration"), "hours").toDate()
|
moment()
|
||||||
|
.add(this.config.get("share.maxExpiration"), "hours")
|
||||||
|
.toDate())
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Expiration date exceeds maximum expiration date",
|
"Expiration date exceeds maximum expiration date",
|
||||||
|
@ -12,7 +12,7 @@ const showShareInformationsModal = (
|
|||||||
modals: ModalsContextProps,
|
modals: ModalsContextProps,
|
||||||
share: MyShare,
|
share: MyShare,
|
||||||
appUrl: string,
|
appUrl: string,
|
||||||
maxShareSize: number
|
maxShareSize: number,
|
||||||
) => {
|
) => {
|
||||||
const t = translateOutsideContext();
|
const t = translateOutsideContext();
|
||||||
const link = `${appUrl}/s/${share.id}`;
|
const link = `${appUrl}/s/${share.id}`;
|
||||||
|
@ -125,11 +125,13 @@ const CreateUploadModalBody = ({
|
|||||||
"",
|
"",
|
||||||
) as moment.unitOfTime.DurationConstructor,
|
) as moment.unitOfTime.DurationConstructor,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
options.maxExpirationInHours != 0 &&
|
options.maxExpirationInHours != 0 &&
|
||||||
|
(form.values.never_expires ||
|
||||||
expirationDate.isAfter(
|
expirationDate.isAfter(
|
||||||
moment().add(options.maxExpirationInHours, "hours"),
|
moment().add(options.maxExpirationInHours, "hours"),
|
||||||
)
|
))
|
||||||
) {
|
) {
|
||||||
form.setFieldError(
|
form.setFieldError(
|
||||||
"expiration_num",
|
"expiration_num",
|
||||||
|
Loading…
Reference in New Issue
Block a user