mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 13:35:07 +00:00
put session by id
This commit is contained in:
@@ -66,13 +66,14 @@ export default async function Page({
|
||||
|
||||
{!sessionFactors && <div className="py-4"></div>}
|
||||
|
||||
{!loginName && (
|
||||
{!(loginName || sessionId) && (
|
||||
<Alert>Provide your active session as loginName param</Alert>
|
||||
)}
|
||||
|
||||
{loginName && (
|
||||
{(loginName || sessionId) && (
|
||||
<LoginPasskey
|
||||
loginName={loginName}
|
||||
sessionId={sessionId}
|
||||
authRequestId={authRequestId}
|
||||
altPassword={altPassword === "true"}
|
||||
organization={organization}
|
||||
|
||||
@@ -63,10 +63,21 @@ export async function PUT(request: NextRequest) {
|
||||
const body = await request.json();
|
||||
|
||||
if (body) {
|
||||
const { loginName, organization, password, webAuthN, authRequestId } = body;
|
||||
const {
|
||||
loginName,
|
||||
sessionId,
|
||||
organization,
|
||||
password,
|
||||
webAuthN,
|
||||
authRequestId,
|
||||
} = body;
|
||||
const challenges: RequestChallenges = body.challenges;
|
||||
|
||||
const recentPromise: Promise<SessionCookie> = loginName
|
||||
const recentPromise: Promise<SessionCookie> = sessionId
|
||||
? getSessionCookieById(sessionId).catch((error) => {
|
||||
return Promise.reject(error);
|
||||
})
|
||||
: loginName
|
||||
? getSessionCookieByLoginName(loginName, organization).catch((error) => {
|
||||
return Promise.reject(error);
|
||||
})
|
||||
|
||||
@@ -7,8 +7,10 @@ import { Button, ButtonVariants } from "./Button";
|
||||
import Alert from "./Alert";
|
||||
import { Spinner } from "./Spinner";
|
||||
|
||||
// either loginName or sessionId must be provided
|
||||
type Props = {
|
||||
loginName: string;
|
||||
loginName?: string;
|
||||
sessionId?: string;
|
||||
authRequestId?: string;
|
||||
altPassword: boolean;
|
||||
organization?: string;
|
||||
@@ -16,6 +18,7 @@ type Props = {
|
||||
|
||||
export default function LoginPasskey({
|
||||
loginName,
|
||||
sessionId,
|
||||
authRequestId,
|
||||
altPassword,
|
||||
organization,
|
||||
@@ -66,6 +69,7 @@ export default function LoginPasskey({
|
||||
},
|
||||
body: JSON.stringify({
|
||||
loginName,
|
||||
sessionId,
|
||||
organization,
|
||||
challenges: {
|
||||
webAuthN: {
|
||||
@@ -94,6 +98,7 @@ export default function LoginPasskey({
|
||||
},
|
||||
body: JSON.stringify({
|
||||
loginName,
|
||||
sessionId,
|
||||
organization,
|
||||
webAuthN: { credentialAssertionData: data },
|
||||
authRequestId,
|
||||
@@ -207,7 +212,15 @@ export default function LoginPasskey({
|
||||
type="button"
|
||||
variant={ButtonVariants.Secondary}
|
||||
onClick={() => {
|
||||
const params: any = { loginName, alt: "true" };
|
||||
const params: any = { alt: "true" };
|
||||
|
||||
if (loginName) {
|
||||
params.loginName = loginName;
|
||||
}
|
||||
|
||||
if (sessionId) {
|
||||
params.sessionId = sessionId;
|
||||
}
|
||||
|
||||
if (authRequestId) {
|
||||
params.authRequestId = authRequestId;
|
||||
|
||||
Reference in New Issue
Block a user