Skip to content

Commit

Permalink
chore: expired session key
Browse files Browse the repository at this point in the history
  • Loading branch information
TwilightLogic committed Jun 17, 2024
1 parent 0a2ac0f commit 3e2df02
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ interface ExpandableRowProps {
}

const isSessionExpired = (createTime: number, maxInactiveInterval: number) => {
const currentTime = Date.now()
const expirationTime = createTime + maxInactiveInterval * 1000
return currentTime > expirationTime
const expirationTime = new Date(createTime).getTime() + maxInactiveInterval * 1000
return Date.now() > expirationTime
}

export const ManageSessions: React.FC = () => {
Expand All @@ -51,9 +50,7 @@ export const ManageSessions: React.FC = () => {
async (authKey: string) => {
setLoading(authKey)
try {
await removeSession({
authKey: authKey,
})
await removeSession({ authKey })
await refetch()
} catch (error) {
console.error(error)
Expand Down Expand Up @@ -98,8 +95,6 @@ export const ManageSessions: React.FC = () => {
)
}

console.log(sessionKeys)

return (
<div className="rounded-lg border w-full">
<Table>
Expand Down Expand Up @@ -135,11 +130,7 @@ const ExpandableRow: React.FC<ExpandableRowProps> = ({ session, remove, loading

const handleCopy = (key: string) => {
copyToClipboard(key, (value) => {
if (value) {
setCopiedKeys((prev) => [...prev, key])
} else {
setCopiedKeys((prev) => prev.filter((item) => item !== key))
}
setCopiedKeys((prev) => (value ? [...prev, key] : prev.filter((item) => item !== key)))
})
}

Expand All @@ -163,11 +154,9 @@ const ExpandableRow: React.FC<ExpandableRowProps> = ({ session, remove, loading
</TableCell>
<TableCell className="text-muted-foreground">
{formatTimestamp(session.createTime)}
{/*{session.createTime}*/}
</TableCell>
<TableCell className="text-muted-foreground">
{formatTimestamp(session.lastActiveTime)}
{/*{session.lastActiveTime}*/}
</TableCell>
<TableCell className="text-muted-foreground">{session.maxInactiveInterval}</TableCell>
<TableCell className="text-center">
Expand Down Expand Up @@ -221,3 +210,5 @@ const ExpandableRow: React.FC<ExpandableRowProps> = ({ session, remove, loading
</>
)
}

export default ManageSessions

0 comments on commit 3e2df02

Please sign in to comment.