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"
},
"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.",
"submit": "Allow"
},

View File

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

View File

@@ -2,8 +2,12 @@ import { Button, ButtonVariants } from "@/components/button";
import { DynamicTheme } from "@/components/dynamic-theme";
import { SelfServiceMenu } from "@/components/self-service-menu";
import { UserAvatar } from "@/components/user-avatar";
import { getMostRecentCookieWithLoginname } from "@/lib/cookies";
import {
getMostRecentCookieWithLoginname,
getSessionCookieById,
} from "@/lib/cookies";
import { getServiceUrlFromHeaders } from "@/lib/service";
import { loadMostRecentSession } from "@/lib/session";
import {
authorizeOrDenyDeviceAuthorization,
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> }) {
const searchParams = await props.searchParams;
const locale = getLocale();
@@ -96,12 +117,15 @@ export default async function Page(props: { searchParams: Promise<any> }) {
const _headers = await 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 = sessionId
? await loadSessionById(serviceUrl, sessionId, organization)
: await loadSessionByLoginname(serviceUrl, loginName, organization);
: await loadMostRecentSession({
serviceUrl,
sessionParams: { loginName, organization },
});
const branding = await getBrandingSettings({
serviceUrl,

View File

@@ -12,7 +12,7 @@ export function ConsentScreen({
const t = useTranslations();
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">
{scope?.map((s) => {
const translationKey = `device.scope.${s}`;
@@ -20,9 +20,7 @@ export function ConsentScreen({
// Check if the key itself is returned and provide a fallback
const resolvedDescription =
description === translationKey
? "No description available."
: description;
description === translationKey ? "" : description;
return (
<li
@@ -36,6 +34,10 @@ export function ConsentScreen({
})}
</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">
<Button variant={ButtonVariants.Destructive} data-testid="deny-button">
Deny