fix(ui): resolves range error that happaned when providing a large ttl in scim

This commit is contained in:
=
2025-12-04 01:18:24 +05:30
parent aa9c125124
commit 02b29b5ae0
2 changed files with 10 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ export const registerScimRouter = async (server: FastifyZodProvider) => {
body: z.object({ body: z.object({
organizationId: z.string().trim(), organizationId: z.string().trim(),
description: z.string().trim().default(""), description: z.string().trim().default(""),
ttlDays: z.number().min(0).default(0) ttlDays: z.number().min(0).max(730).default(0)
}), }),
response: { response: {
200: z.object({ 200: z.object({

View File

@@ -245,15 +245,22 @@ export const ScimTokenModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Pr
data && data &&
data.length > 0 && data.length > 0 &&
data.map(({ id, description, ttlDays, createdAt }) => { data.map(({ id, description, ttlDays, createdAt }) => {
const isInvalidTTLDays = ttlDays > 9999; // added validation later so some users would still be using this
let expiresAt; let expiresAt;
if (ttlDays > 0) { if (ttlDays > 0) {
expiresAt = new Date(new Date(createdAt).getTime() + ttlDays * 86400 * 1000); expiresAt = isInvalidTTLDays
? new Date()
: new Date(new Date(createdAt).getTime() + ttlDays * 86400 * 1000);
} }
return ( return (
<Tr className="h-10 items-center" key={`mi-client-secret-${id}`}> <Tr className="h-10 items-center" key={`mi-client-secret-${id}`}>
<Td>{description === "" ? "-" : description}</Td> <Td>{description === "" ? "-" : description}</Td>
<Td>{expiresAt ? format(expiresAt, "yyyy-MM-dd HH:mm:ss") : "-"}</Td> <Td>
{expiresAt && !isInvalidTTLDays
? format(expiresAt, "yyyy-MM-dd HH:mm:ss")
: "-"}
</Td>
<Td>{format(new Date(createdAt), "yyyy-MM-dd HH:mm:ss")}</Td> <Td>{format(new Date(createdAt), "yyyy-MM-dd HH:mm:ss")}</Td>
<Td> <Td>
<IconButton <IconButton