mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 07:24:51 +00:00
session create with challenge
This commit is contained in:
@@ -31,7 +31,7 @@ export default async function Page() {
|
||||
|
||||
<div className="flex flex-col w-full space-y-2">
|
||||
<SessionsList sessions={sessions} />
|
||||
<Link href="/username">
|
||||
<Link href="/loginname">
|
||||
<div className="flex flex-row items-center py-3 px-4 hover:bg-black/10 dark:hover:bg-white/10 rounded-md transition-all">
|
||||
<div className="w-8 h-8 mr-4 flex flex-row justify-center items-center rounded-full bg-black/5 dark:bg-white/5">
|
||||
<UserPlusIcon className="h-5 w-5" />
|
||||
|
||||
19
apps/login/app/(login)/loginname/[loginname]/page.tsx
Normal file
19
apps/login/app/(login)/loginname/[loginname]/page.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getLoginSettings, server } from "#/lib/zitadel";
|
||||
import UsernameForm from "#/ui/UsernameForm";
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: { loginname: string };
|
||||
}) {
|
||||
const login = await getLoginSettings(server);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center space-y-4">
|
||||
<h1>Welcome back!</h1>
|
||||
<p className="ztdl-p">Enter your login data.</p>
|
||||
|
||||
<UsernameForm />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -54,8 +54,9 @@ export async function POST(request: NextRequest) {
|
||||
const createdSession = await createSession(
|
||||
server,
|
||||
loginName,
|
||||
domain,
|
||||
undefined,
|
||||
domain
|
||||
undefined
|
||||
);
|
||||
|
||||
if (createdSession) {
|
||||
|
||||
@@ -25,8 +25,9 @@ export async function POST(request: NextRequest) {
|
||||
const createdSession = await createSession(
|
||||
server,
|
||||
loginName,
|
||||
domain,
|
||||
password,
|
||||
domain
|
||||
undefined
|
||||
);
|
||||
|
||||
if (createdSession) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
SetSessionResponse,
|
||||
DeleteSessionResponse,
|
||||
VerifyPasskeyRegistrationResponse,
|
||||
ChallengeKind,
|
||||
} from "@zitadel/server";
|
||||
|
||||
export const zitadelConfig: ZitadelServerOptions = {
|
||||
@@ -45,6 +46,15 @@ export async function getBrandingSettings(
|
||||
.then((resp: GetBrandingSettingsResponse) => resp.settings);
|
||||
}
|
||||
|
||||
export async function getLoginSettings(
|
||||
server: ZitadelServer
|
||||
): Promise<LoginSettings | undefined> {
|
||||
const settingsService = settings.getSettings(server);
|
||||
return settingsService
|
||||
.getLoginSettings({}, {})
|
||||
.then((resp: GetLoginSettingsResponse) => resp.settings);
|
||||
}
|
||||
|
||||
export async function getGeneralSettings(
|
||||
server: ZitadelServer
|
||||
): Promise<string[] | undefined> {
|
||||
@@ -78,13 +88,18 @@ export async function getPasswordComplexitySettings(
|
||||
export async function createSession(
|
||||
server: ZitadelServer,
|
||||
loginName: string,
|
||||
domain: string,
|
||||
password: string | undefined,
|
||||
domain: string
|
||||
challenges: ChallengeKind[] | undefined
|
||||
): Promise<CreateSessionResponse | undefined> {
|
||||
const sessionService = session.getSession(server);
|
||||
return password
|
||||
? sessionService.createSession(
|
||||
{ checks: { user: { loginName }, password: { password } }, domain },
|
||||
{
|
||||
checks: { user: { loginName }, password: { password } },
|
||||
challenges,
|
||||
domain,
|
||||
},
|
||||
{}
|
||||
)
|
||||
: sessionService.createSession({ checks: { user: { loginName } } }, {});
|
||||
|
||||
@@ -87,7 +87,7 @@ export default function VerifyEmailForm({ userId, code, submit }: Props) {
|
||||
|
||||
function submitCodeAndContinue(value: Inputs): Promise<boolean | void> {
|
||||
return submitCode(value).then((resp: any) => {
|
||||
return router.push(`/username`);
|
||||
return router.push(`/loginname`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ export {
|
||||
Theme,
|
||||
} from "./proto/server/zitadel/settings/v2alpha/branding_settings";
|
||||
|
||||
export { ChallengeKind } from "./proto/server/zitadel/session/v2alpha/challenge";
|
||||
|
||||
export { Session } from "./proto/server/zitadel/session/v2alpha/session";
|
||||
export {
|
||||
ListSessionsResponse,
|
||||
@@ -25,6 +27,8 @@ export {
|
||||
GetBrandingSettingsResponse,
|
||||
GetLegalAndSupportSettingsResponse,
|
||||
GetGeneralSettingsResponse,
|
||||
GetLoginSettingsResponse,
|
||||
GetLoginSettingsRequest,
|
||||
} from "./proto/server/zitadel/settings/v2alpha/settings_service";
|
||||
export {
|
||||
AddHumanUserResponse,
|
||||
|
||||
Reference in New Issue
Block a user