1
0
Fork 0
mirror of https://gitbruv.vercel.app/api/git/bruv/gitbruv.git synced 2025-12-20 23:24:09 +01:00
This commit is contained in:
Ahmet Kilinc 2025-12-20 02:43:11 +00:00
parent 8f672d012c
commit 46cab693db
49 changed files with 4725 additions and 118 deletions

27
app/(auth)/layout.tsx Normal file
View file

@ -0,0 +1,27 @@
import { GitBranch } from "lucide-react";
import Link from "next/link";
export default function AuthLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<div className="min-h-screen flex flex-col items-center justify-center relative overflow-hidden px-4">
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-accent/15 via-background to-background" />
<div className="absolute inset-0">
<div className="absolute top-1/4 left-1/4 w-[500px] h-[500px] bg-accent/5 rounded-full blur-[100px]" />
<div className="absolute bottom-1/4 right-1/4 w-[400px] h-[400px] bg-primary/5 rounded-full blur-[100px]" />
</div>
<div className="relative z-10 flex flex-col items-center w-full max-w-[400px]">
<Link href="/" className="flex items-center gap-3 mb-10 group">
<div className="relative">
<GitBranch className="w-10 h-10 text-foreground transition-transform group-hover:scale-110" />
</div>
<span className="text-2xl font-bold tracking-tight">gitbruv</span>
</Link>
{children}
</div>
</div>
);
}

97
app/(auth)/login/page.tsx Normal file
View file

@ -0,0 +1,97 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { signIn } from "@/lib/auth-client";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { toast } from "sonner";
import { Loader2 } from "lucide-react";
export default function LoginPage() {
const router = useRouter();
const [loading, setLoading] = useState(false);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setLoading(true);
try {
const { error } = await signIn.email({
email,
password,
});
if (error) {
toast.error(error.message || "Failed to sign in");
return;
}
toast.success("Welcome back!");
router.push("/");
router.refresh();
} catch {
toast.error("Something went wrong");
} finally {
setLoading(false);
}
}
return (
<div className="w-full">
<div className="rounded-xl border border-border bg-card/80 backdrop-blur-sm p-8">
<div className="text-center mb-8">
<h1 className="text-xl font-semibold">Sign in to gitbruv</h1>
</div>
<form onSubmit={handleSubmit} className="space-y-5">
<div className="space-y-2">
<Label htmlFor="email">Email address</Label>
<Input
id="email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="you@example.com"
required
className="bg-input/50 h-11"
/>
</div>
<div className="space-y-2">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="••••••••"
required
className="bg-input/50 h-11"
/>
</div>
<Button type="submit" disabled={loading} className="w-full h-11">
{loading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Signing in...
</>
) : (
"Sign in"
)}
</Button>
</form>
</div>
<div className="mt-6 p-4 rounded-xl border border-border text-center">
<p className="text-sm text-muted-foreground">
New to gitbruv?{" "}
<Link href="/register" className="text-accent hover:underline font-medium">
Create an account
</Link>
</p>
</div>
</div>
);
}

View file

@ -0,0 +1,153 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { signUpWithUsername } from "@/lib/auth-client";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { toast } from "sonner";
import { Loader2 } from "lucide-react";
export default function RegisterPage() {
const router = useRouter();
const [loading, setLoading] = useState(false);
const [formData, setFormData] = useState({
name: "",
username: "",
email: "",
password: "",
});
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setLoading(true);
if (formData.username.length < 3) {
toast.error("Username must be at least 3 characters");
setLoading(false);
return;
}
if (!/^[a-zA-Z0-9_-]+$/.test(formData.username)) {
toast.error("Username can only contain letters, numbers, hyphens, and underscores");
setLoading(false);
return;
}
try {
const { error } = await signUpWithUsername({
email: formData.email,
password: formData.password,
name: formData.name,
username: formData.username.toLowerCase(),
});
if (error) {
toast.error(error.message || "Failed to create account");
return;
}
toast.success("Account created successfully!");
router.push("/");
router.refresh();
} catch {
toast.error("Something went wrong");
} finally {
setLoading(false);
}
}
return (
<div className="w-full">
<div className="rounded-xl border border-border bg-card/80 backdrop-blur-sm p-8">
<div className="text-center mb-8">
<h1 className="text-xl font-semibold">Create your account</h1>
</div>
<form onSubmit={handleSubmit} className="space-y-5">
<div className="space-y-2">
<Label htmlFor="name">Name</Label>
<Input
id="name"
type="text"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
placeholder="John Doe"
required
className="bg-input/50 h-11"
/>
</div>
<div className="space-y-2">
<Label htmlFor="username">Username</Label>
<Input
id="username"
type="text"
value={formData.username}
onChange={(e) => setFormData({ ...formData, username: e.target.value })}
placeholder="johndoe"
required
className="bg-input/50 h-11"
/>
<p className="text-xs text-muted-foreground">
This will be your unique identifier on gitbruv
</p>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email address</Label>
<Input
id="email"
type="email"
value={formData.email}
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
placeholder="you@example.com"
required
className="bg-input/50 h-11"
/>
</div>
<div className="space-y-2">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
value={formData.password}
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
placeholder="••••••••"
required
minLength={8}
className="bg-input/50 h-11"
/>
<p className="text-xs text-muted-foreground">
Must be at least 8 characters
</p>
</div>
<Button
type="submit"
disabled={loading}
className="w-full h-11"
>
{loading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Creating account...
</>
) : (
"Create account"
)}
</Button>
</form>
</div>
<div className="mt-6 p-4 rounded-xl border border-border text-center">
<p className="text-sm text-muted-foreground">
Already have an account?{" "}
<Link
href="/login"
className="text-accent hover:underline font-medium"
>
Sign in
</Link>
</p>
</div>
</div>
);
}