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:
Andymick
2026-07-19 09:51:52 +01:00
co-authored by Claude Haiku 4.5
parent 36cc6dddff
commit 9623ac2fdb
14 changed files with 430 additions and 29 deletions
@@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "AdminUser" (
"id" TEXT NOT NULL,
"username" TEXT NOT NULL,
"passwordHash" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "AdminUser_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "AdminUser_username_key" ON "AdminUser"("username");
+9
View File
@@ -449,6 +449,15 @@ model OrderItem {
designImageDimensions String? // JSON array of {imageId, widthCm, heightCm} for each uploaded image
}
// Admin user account — stores admin credentials (can override env vars if present)
model AdminUser {
id String @id @default(cuid())
username String @unique
passwordHash String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// Audit log for admin logins — tracks when the admin panel is accessed
model AdminLoginLog {
id String @id @default(cuid())