Files
zitadel/apps/login/src/components/consent.tsx
T
0945195f68 chore: deps update (#11968)
# Which Problems Are Solved
This pr updates major and minor dependencies and is the first step on
getting our dependabot alerts cut down.

# How the Problems Are Solved

Depedency updates across the board eg:
- Upgrade Angular to v21
- Upgrade next.js to v16.2
- Upgrade tailwind to v4 in the login
- Upgrade vitest to v4 in the login

This is an uncompleted list refer to the changed files for a full
overview of all the updates.

# Additional Changes

Migrated all control flow in the console to the modern control flow
syntax.
Fixed the dependsOn setting for the @zitadel/login:test-unit nx target.

# Additional Context

- Closes https://github.com/zitadel/zitadel/issues/11274

---------

Co-authored-by: Max Peintner <[email protected]>
2026-04-02 15:53:08 +02:00

105 lines
3.2 KiB
TypeScript

"use client";
import { completeDeviceAuthorization } from "@/lib/server/device";
import { useTranslations } from "next-intl";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { Alert } from "./alert";
import { Button, ButtonVariants } from "./button";
import { Spinner } from "./spinner";
import { Translated } from "./translated";
export function ConsentScreen({
scope,
nextUrl,
deviceAuthorizationRequestId,
appName,
}: {
scope?: string[];
nextUrl: string;
deviceAuthorizationRequestId: string;
appName?: string;
}) {
const t = useTranslations();
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string>("");
const router = useRouter();
async function denyDeviceAuth() {
setLoading(true);
const response = await completeDeviceAuthorization(deviceAuthorizationRequestId)
.catch(() => {
setError("Could not register user");
return;
})
.finally(() => {
setLoading(false);
});
if (response) {
return router.push("/device");
}
}
const scopes = scope?.filter((s) => !!s);
return (
<div className="flex w-full flex-col items-center space-y-4 pt-4">
<ul className="w-full list-disc space-y-2">
{scopes?.length === 0 && (
<span className="border-divider-light bg-background-light-400 dark:bg-background-dark-400 flex w-full flex-row items-center rounded-md border px-4 py-2 text-sm transition-all">
<Translated i18nKey="device.scope.openid" namespace="device" />
</span>
)}
{scopes?.map((s) => {
const translationKey = `device.scope.${s}`;
const description = t(translationKey);
// Check if the key itself is returned and provide a fallback
const resolvedDescription = description === translationKey ? "" : description;
return (
<li
key={s}
className="border-divider-light bg-background-light-400 dark:bg-background-dark-400 flex w-full flex-row items-center rounded-md border px-4 py-2 text-sm transition-all"
>
<span>{resolvedDescription}</span>
</li>
);
})}
</ul>
<p className="ztdl-p text-left text-xs">
<Translated i18nKey="request.disclaimer" namespace="device" data={{ appName: appName }} />
</p>
{error && (
<div className="py-4">
<Alert>{error}</Alert>
</div>
)}
<div className="mt-4 flex w-full flex-row items-center">
<Button
onClick={() => {
denyDeviceAuth();
}}
variant={ButtonVariants.Secondary}
data-testid="deny-button"
>
{loading && <Spinner className="mr-2 h-5 w-5" />}
<Translated i18nKey="device.request.deny" namespace="device" />
</Button>
<span className="flex-grow"></span>
<Link href={nextUrl}>
<Button data-testid="submit-button" type="submit" className="self-end" variant={ButtonVariants.Primary}>
<Translated i18nKey="device.request.submit" namespace="device" />
</Button>
</Link>
</div>
</div>
);
}