refactor: run formatter
This commit is contained in:
@@ -345,7 +345,9 @@ export class AuthService {
|
|||||||
if (refreshToken) {
|
if (refreshToken) {
|
||||||
const now = moment();
|
const now = moment();
|
||||||
const sessionDuration = this.config.get("general.sessionDuration");
|
const sessionDuration = this.config.get("general.sessionDuration");
|
||||||
const maxAge = moment(now).add(sessionDuration.value, sessionDuration.unit).diff(now);
|
const maxAge = moment(now)
|
||||||
|
.add(sessionDuration.value, sessionDuration.unit)
|
||||||
|
.diff(now);
|
||||||
response.cookie("refresh_token", refreshToken, {
|
response.cookie("refresh_token", refreshToken, {
|
||||||
path: "/api/auth/token",
|
path: "/api/auth/token",
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ export class ConfigService extends EventEmitter {
|
|||||||
if (configVariable.type == "boolean") return value == "true";
|
if (configVariable.type == "boolean") return value == "true";
|
||||||
if (configVariable.type == "string" || configVariable.type == "text")
|
if (configVariable.type == "string" || configVariable.type == "text")
|
||||||
return value;
|
return value;
|
||||||
if (configVariable.type == "timespan")
|
if (configVariable.type == "timespan") return stringToTimespan(value);
|
||||||
return stringToTimespan(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getByCategory(category: string) {
|
async getByCategory(category: string) {
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ export class ShareService {
|
|||||||
maxExpiration.value !== 0 &&
|
maxExpiration.value !== 0 &&
|
||||||
(expiresNever ||
|
(expiresNever ||
|
||||||
parsedExpiration >
|
parsedExpiration >
|
||||||
moment()
|
moment().add(maxExpiration.value, maxExpiration.unit).toDate())
|
||||||
.add(maxExpiration.value, maxExpiration.unit)
|
|
||||||
.toDate())
|
|
||||||
) {
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Expiration date exceeds maximum expiration date",
|
"Expiration date exceeds maximum expiration date",
|
||||||
|
|||||||
@@ -96,7 +96,9 @@ const AdminConfigInput = ({
|
|||||||
{configVariable.type == "timespan" && (
|
{configVariable.type == "timespan" && (
|
||||||
<TimespanInput
|
<TimespanInput
|
||||||
value={stringToTimespan(configVariable.value)}
|
value={stringToTimespan(configVariable.value)}
|
||||||
onChange={(timespan) => onValueChange(configVariable, timespanToString(timespan))}
|
onChange={(timespan) =>
|
||||||
|
onValueChange(configVariable, timespanToString(timespan))
|
||||||
|
}
|
||||||
w={201}
|
w={201}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ import { Timespan } from "../../types/timespan.type";
|
|||||||
import { NativeSelect, NumberInput } from "@mantine/core";
|
import { NativeSelect, NumberInput } from "@mantine/core";
|
||||||
import useTranslate from "../../hooks/useTranslate.hook";
|
import useTranslate from "../../hooks/useTranslate.hook";
|
||||||
|
|
||||||
const TimespanInput = ({ label, value, onChange, ...restProps }: {
|
const TimespanInput = ({
|
||||||
label?: string,
|
label,
|
||||||
value: Timespan,
|
value,
|
||||||
onChange: (timespan: Timespan) => void,
|
onChange,
|
||||||
[key: string]: any,
|
...restProps
|
||||||
|
}: {
|
||||||
|
label?: string;
|
||||||
|
value: Timespan;
|
||||||
|
onChange: (timespan: Timespan) => void;
|
||||||
|
[key: string]: any;
|
||||||
}) => {
|
}) => {
|
||||||
const [unit, setUnit] = useState(value.unit);
|
const [unit, setUnit] = useState(value.unit);
|
||||||
const [inputValue, setInputValue] = useState(value.value);
|
const [inputValue, setInputValue] = useState(value.value);
|
||||||
@@ -53,7 +58,7 @@ const TimespanInput = ({ label, value, onChange, ...restProps }: {
|
|||||||
marginRight: -2,
|
marginRight: -2,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onChange={event => {
|
onChange={(event) => {
|
||||||
const unit = event.currentTarget.value as Timespan["unit"];
|
const unit = event.currentTarget.value as Timespan["unit"];
|
||||||
setUnit(unit);
|
setUnit(unit);
|
||||||
onChange({ value: inputValue, unit });
|
onChange({ value: inputValue, unit });
|
||||||
@@ -70,7 +75,7 @@ const TimespanInput = ({ label, value, onChange, ...restProps }: {
|
|||||||
precision={0}
|
precision={0}
|
||||||
rightSection={unitSelect}
|
rightSection={unitSelect}
|
||||||
rightSectionWidth={120}
|
rightSectionWidth={120}
|
||||||
onChange={value => {
|
onChange={(value) => {
|
||||||
const inputVal = value || 0;
|
const inputVal = value || 0;
|
||||||
setInputValue(inputVal);
|
setInputValue(inputVal);
|
||||||
onChange({ value: inputVal, unit });
|
onChange({ value: inputVal, unit });
|
||||||
|
|||||||
@@ -184,7 +184,10 @@ const CreateUploadModalBody = ({
|
|||||||
options.maxExpiration.value != 0 &&
|
options.maxExpiration.value != 0 &&
|
||||||
(form.values.never_expires ||
|
(form.values.never_expires ||
|
||||||
expirationDate.isAfter(
|
expirationDate.isAfter(
|
||||||
moment().add(options.maxExpiration.value, options.maxExpiration.unit),
|
moment().add(
|
||||||
|
options.maxExpiration.value,
|
||||||
|
options.maxExpiration.unit,
|
||||||
|
),
|
||||||
))
|
))
|
||||||
) {
|
) {
|
||||||
form.setFieldError(
|
form.setFieldError(
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ const get = (key: string, configVariables: Config[]): any => {
|
|||||||
if (configVariable.type == "boolean") return value == "true";
|
if (configVariable.type == "boolean") return value == "true";
|
||||||
if (configVariable.type == "string" || configVariable.type == "text")
|
if (configVariable.type == "string" || configVariable.type == "text")
|
||||||
return value;
|
return value;
|
||||||
if (configVariable.type == "timespan")
|
if (configVariable.type == "timespan") return stringToTimespan(value);
|
||||||
return stringToTimespan(value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const finishSetup = async (): Promise<AdminConfig[]> => {
|
const finishSetup = async (): Promise<AdminConfig[]> => {
|
||||||
|
|||||||
@@ -1,2 +1,8 @@
|
|||||||
export type TimeUnit = "minutes" | "hours" | "days" | "weeks" | "months" | "years";
|
export type TimeUnit =
|
||||||
|
| "minutes"
|
||||||
|
| "hours"
|
||||||
|
| "days"
|
||||||
|
| "weeks"
|
||||||
|
| "months"
|
||||||
|
| "years";
|
||||||
export type Timespan = { value: number; unit: TimeUnit };
|
export type Timespan = { value: number; unit: TimeUnit };
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const getExpirationPreview = (
|
|||||||
|
|
||||||
export const timespanToString = (timespan: Timespan) => {
|
export const timespanToString = (timespan: Timespan) => {
|
||||||
return `${timespan.value} ${timespan.unit}`;
|
return `${timespan.value} ${timespan.unit}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const stringToTimespan = (value: string): Timespan => {
|
export const stringToTimespan = (value: string): Timespan => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user