feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
// app/(auth)/layout.tsx
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
openGraph: { type: "website" },
|
||||
};
|
||||
|
||||
export default function AuthLayout({
|
||||
children,
|
||||
}: {
|
||||
|
||||
10
thoughts-frontend/app/(auth)/login/layout.tsx
Normal file
10
thoughts-frontend/app/(auth)/login/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Sign in",
|
||||
description: "Sign in to your Thoughts account",
|
||||
};
|
||||
|
||||
export default function LoginLayout({ children }: { children: React.ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export default function LoginPage() {
|
||||
|
||||
const form = useForm<z.infer<typeof LoginSchema>>({
|
||||
resolver: zodResolver(LoginSchema),
|
||||
defaultValues: { username: "", password: "" },
|
||||
defaultValues: { email: "", password: "" },
|
||||
});
|
||||
|
||||
async function onSubmit(values: z.infer<typeof LoginSchema>) {
|
||||
@@ -43,7 +43,7 @@ export default function LoginPage() {
|
||||
setToken(token);
|
||||
router.push("/"); // Redirect to homepage on successful login
|
||||
} catch {
|
||||
setError("Invalid username or password.");
|
||||
setError("Invalid email or password.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ export default function LoginPage() {
|
||||
{/* ... Form fields for username and password ... */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="username"
|
||||
name="email"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Username</FormLabel>
|
||||
<FormLabel>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="frutiger" {...field} />
|
||||
<Input type="email" placeholder="you@example.com" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
10
thoughts-frontend/app/(auth)/register/layout.tsx
Normal file
10
thoughts-frontend/app/(auth)/register/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Join Thoughts",
|
||||
description: "Create an account on Thoughts and connect across the Fediverse",
|
||||
};
|
||||
|
||||
export default function RegisterLayout({ children }: { children: React.ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { RegisterSchema, registerUser } from "@/lib/api";
|
||||
import Cookies from "js-cookie";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function RegisterPage() {
|
||||
@@ -37,9 +38,9 @@ export default function RegisterPage() {
|
||||
async function onSubmit(values: z.infer<typeof RegisterSchema>) {
|
||||
try {
|
||||
setError(null);
|
||||
await registerUser(values);
|
||||
// You can automatically log the user in here or just redirect them
|
||||
router.push("/login");
|
||||
const { token } = await registerUser(values);
|
||||
Cookies.set("auth_token", token, { expires: 7, secure: true });
|
||||
router.push("/");
|
||||
} catch {
|
||||
setError("Username or email may already be taken.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user