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