feat(user-auth): use ms library and update docs

This commit is contained in:
carlosmonastyrski
2025-04-30 16:49:33 -03:00
parent 6d5a6f42e0
commit c99440ba81
3 changed files with 9 additions and 18 deletions

View File

@@ -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 => {

View File

@@ -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)
<Tip>
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.
</Tip>
## Access Control
The **Access Control** page is where you can manage identities (both people and machines) that are part of your organization.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 519 KiB

After

Width:  |  Height:  |  Size: 352 KiB