This commit is contained in:
peintnermax
2023-08-31 09:38:58 +02:00
parent e475418ce1
commit 101d11ac2f
4 changed files with 1 additions and 47 deletions

View File

@@ -2,13 +2,11 @@ import { createCallback, getSession, server } from "#/lib/zitadel";
import UserAvatar from "#/ui/UserAvatar";
import { getMostRecentCookieWithLoginname } from "#/utils/cookies";
import { redirect } from "next/navigation";
import { NextResponse } from "next/server";
async function loadSession(loginName: string, authRequestId?: string) {
const recent = await getMostRecentCookieWithLoginname(`${loginName}`);
if (authRequestId) {
console.log(authRequestId);
return createCallback(server, {
authRequestId,
session: { sessionId: recent.id, sessionToken: recent.token },

View File

@@ -1,52 +1,12 @@
import {
getSession,
listAuthenticationMethodTypes,
server,
} from "#/lib/zitadel";
import { getSessionCookieById } from "#/utils/cookies";
import { listAuthenticationMethodTypes } from "#/lib/zitadel";
import { createSessionAndUpdateCookie } from "#/utils/session";
import { NextRequest, NextResponse } from "next/server";
// export async function GET(request: NextRequest) {
// const { searchParams } = new URL(request.url);
// const sessionId = searchParams.get("sessionId");
// if (sessionId) {
// const sessionCookie = await getSessionCookieById(sessionId);
// const session = await getSession(
// server,
// sessionCookie.id,
// sessionCookie.token
// );
// const userId = session?.session?.factors?.user?.id;
// if (userId) {
// return listAuthenticationMethodTypes(userId)
// .then((methods) => {
// return NextResponse.json(methods);
// })
// .catch((error) => {
// return NextResponse.json(error, { status: 500 });
// });
// } else {
// return NextResponse.json(
// { details: "could not get session" },
// { status: 500 }
// );
// }
// } else {
// return NextResponse.json({}, { status: 400 });
// }
// }
export async function POST(request: NextRequest) {
const body = await request.json();
if (body) {
const { loginName, authRequestId } = body;
// const domain: string = request.nextUrl.hostname;
return createSessionAndUpdateCookie(
loginName,
undefined,

View File

@@ -18,8 +18,6 @@ export async function POST(request: NextRequest) {
if (body) {
const { loginName, password } = body;
// const domain: string = request.nextUrl.hostname;
return createSessionAndUpdateCookie(
loginName,
password,

View File

@@ -31,7 +31,6 @@ export default function LoginPasskey({
setLoading(true);
updateSessionForChallenge()
.then((response) => {
console.log(response);
const pK =
response.challenges.webAuthN.publicKeyCredentialRequestOptions
.publicKey;
@@ -85,7 +84,6 @@ export default function LoginPasskey({
async function submitLogin(data: any) {
setLoading(true);
console.log(data);
const res = await fetch("/api/session", {
method: "PUT",
headers: {