fix signedin session

This commit is contained in:
Max Peintner
2025-05-05 09:39:50 +02:00
parent 54fd748b12
commit 781462d9f1
4 changed files with 38 additions and 10 deletions

View File

@@ -194,7 +194,7 @@
"submit": "Continue" "submit": "Continue"
}, },
"request": { "request": {
"title": "would like to connect:", "title": "{appName} would like to connect:",
"description": "By clicking Allow, you allow this app and Zitadel to use your information in accordance with their respective terms of service and privacy policies. You can revoke this access at any time.", "description": "By clicking Allow, you allow this app and Zitadel to use your information in accordance with their respective terms of service and privacy policies. You can revoke this access at any time.",
"submit": "Allow" "submit": "Allow"
}, },

View File

@@ -66,8 +66,10 @@ export default async function Page(props: {
appName={deviceAuthorizationRequest?.appName} appName={deviceAuthorizationRequest?.appName}
> >
<div className="flex flex-col items-center space-y-4"> <div className="flex flex-col items-center space-y-4">
<h1>{t("usercode.title")}</h1> <h1>
<p className="ztdl-p">{t("usercode.description")}</p> {t("request.title", { appName: deviceAuthorizationRequest?.appName })}
</h1>
<ConsentScreen <ConsentScreen
scope={deviceAuthorizationRequest?.scope} scope={deviceAuthorizationRequest?.scope}
nextUrl={`/loginname?` + params} nextUrl={`/loginname?` + params}

View File

@@ -2,8 +2,12 @@ import { Button, ButtonVariants } from "@/components/button";
import { DynamicTheme } from "@/components/dynamic-theme"; import { DynamicTheme } from "@/components/dynamic-theme";
import { SelfServiceMenu } from "@/components/self-service-menu"; import { SelfServiceMenu } from "@/components/self-service-menu";
import { UserAvatar } from "@/components/user-avatar"; import { UserAvatar } from "@/components/user-avatar";
import { getMostRecentCookieWithLoginname } from "@/lib/cookies"; import {
getMostRecentCookieWithLoginname,
getSessionCookieById,
} from "@/lib/cookies";
import { getServiceUrlFromHeaders } from "@/lib/service"; import { getServiceUrlFromHeaders } from "@/lib/service";
import { loadMostRecentSession } from "@/lib/session";
import { import {
authorizeOrDenyDeviceAuthorization, authorizeOrDenyDeviceAuthorization,
createCallback, createCallback,
@@ -88,6 +92,23 @@ async function loadSession(
}); });
} }
async function loadSessionById(
serviceUrl: string,
sessionId: string,
organization?: string,
) {
const recent = await getSessionCookieById({ sessionId, organization });
return getSession({
serviceUrl,
sessionId: recent.id,
sessionToken: recent.token,
}).then((response) => {
if (response?.session) {
return response.session;
}
});
}
export default async function Page(props: { searchParams: Promise<any> }) { export default async function Page(props: { searchParams: Promise<any> }) {
const searchParams = await props.searchParams; const searchParams = await props.searchParams;
const locale = getLocale(); const locale = getLocale();
@@ -96,12 +117,15 @@ export default async function Page(props: { searchParams: Promise<any> }) {
const _headers = await headers(); const _headers = await headers();
const { serviceUrl } = getServiceUrlFromHeaders(_headers); const { serviceUrl } = getServiceUrlFromHeaders(_headers);
const { loginName, requestId, organization } = searchParams; const { loginName, requestId, organization, sessionId } = searchParams;
// const sessionFactors = await loadSession(serviceUrl, loginName, requestId); // const sessionFactors = await loadSession(serviceUrl, loginName, requestId);
const sessionFactors = sessionId const sessionFactors = sessionId
? await loadSessionById(serviceUrl, sessionId, organization) ? await loadSessionById(serviceUrl, sessionId, organization)
: await loadSessionByLoginname(serviceUrl, loginName, organization); : await loadMostRecentSession({
serviceUrl,
sessionParams: { loginName, organization },
});
const branding = await getBrandingSettings({ const branding = await getBrandingSettings({
serviceUrl, serviceUrl,

View File

@@ -12,7 +12,7 @@ export function ConsentScreen({
const t = useTranslations(); const t = useTranslations();
return ( return (
<div className="w-full flex flex-col items-center space-y-4"> <div className="pt-4 w-full flex flex-col items-center space-y-4">
<ul className="list-disc space-y-2 w-full"> <ul className="list-disc space-y-2 w-full">
{scope?.map((s) => { {scope?.map((s) => {
const translationKey = `device.scope.${s}`; const translationKey = `device.scope.${s}`;
@@ -20,9 +20,7 @@ export function ConsentScreen({
// Check if the key itself is returned and provide a fallback // Check if the key itself is returned and provide a fallback
const resolvedDescription = const resolvedDescription =
description === translationKey description === translationKey ? "" : description;
? "No description available."
: description;
return ( return (
<li <li
@@ -36,6 +34,10 @@ export function ConsentScreen({
})} })}
</ul> </ul>
<p className="ztdl-p text-xs text-left">
{t("device.request.description")}
</p>
<div className="mt-4 flex w-full flex-row items-center"> <div className="mt-4 flex w-full flex-row items-center">
<Button variant={ButtonVariants.Destructive} data-testid="deny-button"> <Button variant={ButtonVariants.Destructive} data-testid="deny-button">
Deny Deny