mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-15 18:02:13 +00:00
move client code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { timestampDate } from "@zitadel/client";
|
||||
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
||||
import { GetSessionResponse } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { getMostRecentCookieWithLoginname } from "./cookies";
|
||||
@@ -16,16 +15,3 @@ export async function loadMostRecentSession(sessionParams: {
|
||||
.getSession({ sessionId: recent.id, sessionToken: recent.token }, {})
|
||||
.then((resp: GetSessionResponse) => resp.session);
|
||||
}
|
||||
|
||||
export function isSessionValid(session: Partial<Session>) {
|
||||
const validPassword = session?.factors?.password?.verifiedAt;
|
||||
const validPasskey = session?.factors?.webAuthN?.verifiedAt;
|
||||
const stillValid = session.expirationDate
|
||||
? timestampDate(session.expirationDate) > new Date()
|
||||
: true;
|
||||
|
||||
const verifiedAt = validPassword || validPasskey;
|
||||
const valid = (validPassword || validPasskey) && stillValid;
|
||||
|
||||
return { valid, verifiedAt };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user