mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 12:03:17 +00:00
loginname, password org context
This commit is contained in:
@@ -6,6 +6,7 @@ export type SessionCookie = {
|
||||
id: string;
|
||||
token: string;
|
||||
loginName: string;
|
||||
organization: string;
|
||||
creationDate: string;
|
||||
expirationDate: string;
|
||||
changeDate: string;
|
||||
@@ -226,17 +227,24 @@ export async function getAllSessions(
|
||||
* @returns most recent session
|
||||
*/
|
||||
export async function getMostRecentCookieWithLoginname(
|
||||
loginName?: string
|
||||
loginName?: string,
|
||||
organization?: string
|
||||
): Promise<any> {
|
||||
const cookiesList = cookies();
|
||||
const stringifiedCookie = cookiesList.get("sessions");
|
||||
|
||||
if (stringifiedCookie?.value) {
|
||||
const sessions: SessionCookie[] = JSON.parse(stringifiedCookie?.value);
|
||||
const filtered = sessions.filter((cookie) => {
|
||||
let filtered = sessions.filter((cookie) => {
|
||||
return !!loginName ? cookie.loginName === loginName : true;
|
||||
});
|
||||
|
||||
if (organization) {
|
||||
filtered = filtered.filter((cookie) => {
|
||||
return cookie.organization === organization;
|
||||
});
|
||||
}
|
||||
|
||||
const latest =
|
||||
filtered && filtered.length
|
||||
? filtered.reduce((prev, current) => {
|
||||
|
||||
Reference in New Issue
Block a user