Feat: Login redirects to /dash

This commit is contained in:
2026-03-16 11:31:07 -07:00
parent 3da40a1bf9
commit 72dc03dffd

View File

@@ -35,7 +35,7 @@ export default function LoginPage() {
setCaptcha(''); setCaptcha('');
} else { } else {
setSuccess(data.message); setSuccess(data.message);
router.push('/paper'); router.push(data.redirect || '/dash');
} }
}; };
@@ -50,56 +50,21 @@ export default function LoginPage() {
<form onSubmit={handleLogin} className="space-y-4"> <form onSubmit={handleLogin} className="space-y-4">
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Email</label> <label className="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input <input type="email" required className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow" value={email} onChange={(e) => setEmail(e.target.value)} />
type="email"
required
className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div> </div>
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Password</label> <label className="block text-sm font-medium text-gray-700 mb-1">Password</label>
<input <input type="password" required className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow" value={password} onChange={(e) => setPassword(e.target.value)} />
type="password"
required
className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</div> </div>
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1">Captcha Verification</label> <label className="block text-sm font-medium text-gray-700 mb-1">Captcha Verification</label>
<div className="flex items-center space-x-3 mb-2"> <div className="flex items-center space-x-3 mb-2">
<img <img ref={captchaImgRef} src="/api/captcha" alt="captcha" className="h-12 rounded cursor-pointer border border-gray-300" onClick={refreshCaptcha} title="Click to refresh" />
ref={captchaImgRef} <button type="button" onClick={refreshCaptcha} className="text-sm font-medium text-[#28CC95] hover:opacity-80 transition-opacity">Refresh</button>
src="/api/captcha"
alt="captcha"
className="h-12 rounded cursor-pointer border border-gray-300"
onClick={refreshCaptcha}
title="Click to refresh"
/>
<button type="button" onClick={refreshCaptcha} className="text-sm font-medium text-[#28CC95] hover:opacity-80 transition-opacity">
Refresh
</button>
</div> </div>
<input <input type="text" required placeholder="Enter the text above" className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow" value={captcha} onChange={(e) => setCaptcha(e.target.value)} />
type="text"
required
placeholder="Enter the text above"
className="w-full bg-white border border-gray-300 rounded px-3 py-2 focus:outline-none focus:border-[#28CC95] focus:ring-1 focus:ring-[#28CC95] transition-shadow"
value={captcha}
onChange={(e) => setCaptcha(e.target.value)}
/>
</div> </div>
<button type="submit" className="w-full bg-[#28CC95] hover:brightness-95 text-white font-bold py-2 px-4 rounded transition-all mt-6 shadow-sm">Login</button>
<button
type="submit"
className="w-full bg-[#28CC95] hover:brightness-95 text-white font-bold py-2 px-4 rounded transition-all mt-6 shadow-sm"
>
Login
</button>
</form> </form>
</div> </div>
</div> </div>