feat: add auth pages
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
import Home from "~/components/home";
|
||||
import type { Route } from "./+types/_index";
|
||||
import { auth } from "../../lib/auth";
|
||||
import { redirect } from "react-router";
|
||||
|
||||
export async function loader({ request }: Route.LoaderArgs) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
});
|
||||
|
||||
if (!session) {
|
||||
throw redirect("/log-in");
|
||||
}
|
||||
|
||||
return { session };
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
return <Home />;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { redirect } from "react-router";
|
||||
import type { Route } from "./+types/log-in";
|
||||
import { auth } from "../../lib/auth";
|
||||
import Login from "~/components/login";
|
||||
|
||||
export async function loader({ request }: Route.LoaderArgs) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
});
|
||||
|
||||
if (session) {
|
||||
throw redirect("/");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default function LogInPage() {
|
||||
return <Login />;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { redirect } from "react-router";
|
||||
import SignUp from "~/components/signup";
|
||||
import type { Route } from "../+types/root";
|
||||
import { auth } from "../../lib/auth";
|
||||
|
||||
export async function loader({ request }: Route.LoaderArgs) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
});
|
||||
|
||||
if (session) {
|
||||
throw redirect("/");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default function SignUpPage() {
|
||||
return <SignUp />;
|
||||
}
|
||||
Reference in New Issue
Block a user