Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
|
||||
import { serverOnly$ } from "vite-env-only/macros";
|
||||
import AuthService from "~/modules/users/services/AuthService";
|
||||
import { getUserInfo } from "~/utils/session.server";
|
||||
|
||||
// D1 — tenant-faehige Verify-Route fuer das 2FA-Login-Gate. Der Login (AuthService.loginFromRequest)
|
||||
// schreibt nach Passwort-OK den Pending-Zustand (`pendingMfaUserId`) ins Cookie und schickt den
|
||||
// Client hierher. Diese Route liest den Pending-Zustand, prueft den zweiten Faktor und erstellt
|
||||
// erst dann die echte Session. Route wird per Ordner-Konvention autoregistriert (login-mfa.tsx).
|
||||
|
||||
export type LoaderData = {
|
||||
redirectTo: string;
|
||||
};
|
||||
|
||||
export type ActionData = {
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export const loader = serverOnly$(async ({ request }: LoaderFunctionArgs) => {
|
||||
const userInfo = await getUserInfo(request);
|
||||
// Bereits voll eingeloggt -> hier nichts zu tun.
|
||||
if (userInfo.userId) {
|
||||
throw redirect("/");
|
||||
}
|
||||
// Kein laufender 2FA-Login -> zurueck zur Anmeldung.
|
||||
if (!userInfo.pendingMfaUserId) {
|
||||
throw redirect("/login");
|
||||
}
|
||||
return Response.json({ redirectTo: userInfo.pendingMfaRedirectTo ?? "" } satisfies LoaderData);
|
||||
})!;
|
||||
|
||||
export const action = serverOnly$(async ({ request }: ActionFunctionArgs) => {
|
||||
const form = await request.formData();
|
||||
return AuthService.verifyMfaLoginFromRequest(request, form);
|
||||
})!;
|
||||
Reference in new issue
Block a user