diff --git a/backend/src/lib/fn/time.ts b/backend/src/lib/fn/time.ts index a7fca66e8..27bd8f8a6 100644 --- a/backend/src/lib/fn/time.ts +++ b/backend/src/lib/fn/time.ts @@ -1,29 +1,16 @@ +import ms, { StringValue } from "ms"; + const convertToMilliseconds = (exp: string | number): number => { if (typeof exp === "number") { return exp * 1000; } - const match = exp.match(/^(\d+)\s*([a-z]*)$/i); - if (!match) { + const result = ms(exp as StringValue); + if (typeof result !== "number") { throw new Error(`Invalid expiration format: ${exp}`); } - const value = parseInt(match[1], 10); - const unit = match[2].toLowerCase(); - - switch (unit) { - case "": - case "s": - return value * 1000; // seconds - case "m": - return value * 60 * 1000; // minutes - case "h": - return value * 60 * 60 * 1000; // hours - case "d": - return value * 24 * 60 * 60 * 1000; // days - default: - throw new Error(`Unsupported time unit: ${unit}`); - } + return result; }; export const getMinExpiresIn = (exp1: string | number, exp2: string | number): string | number => { diff --git a/docs/documentation/platform/organization.mdx b/docs/documentation/platform/organization.mdx index f1c62ff37..3a53484fb 100644 --- a/docs/documentation/platform/organization.mdx +++ b/docs/documentation/platform/organization.mdx @@ -27,6 +27,10 @@ The **Settings** page lets you manage information about your organization includ ![organization settings auth](../../images/platform/organization/organization-settings-auth.png) + + You can adjust the maximum time a user token will remain valid for your organization. After this period, users will be required to re-authenticate. This helps improve security by enforcing regular sign-ins. + + ## Access Control The **Access Control** page is where you can manage identities (both people and machines) that are part of your organization. diff --git a/docs/images/platform/organization/organization-settings-auth.png b/docs/images/platform/organization/organization-settings-auth.png index ca2340e9f..fd7a946e0 100644 Binary files a/docs/images/platform/organization/organization-settings-auth.png and b/docs/images/platform/organization/organization-settings-auth.png differ