Feature: Add password change functionality for admin and customers
- Add customer password change page at /account/change-password - Add admin password change page at /admin/change-password - Create AdminUser database table for storing admin credentials - Admin login now checks database first, falls back to env vars - Update admin auth to support bcrypt password hashing - Add change password links to customer account and admin nav - Fix customer login logs back link (was pointing to non-existent /admin) - Add success/error message handling for password changes Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
36cc6dddff
commit
9623ac2fdb
@@ -25,10 +25,16 @@ function statusClasses(status: string, trackingNumber?: string | null) {
|
||||
return 'bg-splash-orange/10 text-splash-orange';
|
||||
}
|
||||
|
||||
export default async function AccountPage() {
|
||||
const SUCCESS_MESSAGES: Record<string, string> = {
|
||||
password_changed: 'Password updated successfully.',
|
||||
};
|
||||
|
||||
export default async function AccountPage({ searchParams }: { searchParams: { success?: string } }) {
|
||||
const customer = await getCurrentCustomer();
|
||||
if (!customer) redirect('/account/login');
|
||||
|
||||
const success = searchParams.success ? SUCCESS_MESSAGES[searchParams.success] : null;
|
||||
|
||||
const orders = await prisma.order.findMany({
|
||||
where: { customerId: customer.id },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
@@ -50,6 +56,11 @@ export default async function AccountPage() {
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-3xl px-6 py-12">
|
||||
{success && (
|
||||
<div className="mb-6 border border-green-500/40 bg-green-500/10 px-4 py-3 text-sm text-green-700">
|
||||
✓ {success}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-baseline justify-between gap-3">
|
||||
<div>
|
||||
<h1 className="font-display text-3xl">My account</h1>
|
||||
@@ -58,14 +69,22 @@ export default async function AccountPage() {
|
||||
{customer.email}
|
||||
</p>
|
||||
</div>
|
||||
<form action={logoutCustomer}>
|
||||
<button
|
||||
type="submit"
|
||||
<div className="flex gap-3">
|
||||
<Link
|
||||
href="/account/change-password"
|
||||
className="tag-label border border-line px-3 py-1.5 hover:border-clay hover:text-clay"
|
||||
>
|
||||
Log out
|
||||
</button>
|
||||
</form>
|
||||
Change password
|
||||
</Link>
|
||||
<form action={logoutCustomer}>
|
||||
<button
|
||||
type="submit"
|
||||
className="tag-label border border-line px-3 py-1.5 hover:border-clay hover:text-clay"
|
||||
>
|
||||
Log out
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AddressFormSection customer={customer} />
|
||||
|
||||
Reference in New Issue
Block a user