diff --git a/scripts/perf-test.ts b/scripts/perf-test.ts index f6a07e7..32ddade 100644 --- a/scripts/perf-test.ts +++ b/scripts/perf-test.ts @@ -64,7 +64,6 @@ const WARMUP_RUNS = 1; // Pages to test const TEST_PAGES: PageTestConfig[] = [ { name: "Home", path: "/" }, - { name: "About", path: "/about" }, { name: "Blog Index", path: "/blog" }, { name: "Blog Post (basic)", path: "/blog/I_made_a_macOS_app_in_a_day" }, { diff --git a/src/config.ts b/src/config.ts index 2598732..61b0c58 100644 --- a/src/config.ts +++ b/src/config.ts @@ -147,7 +147,7 @@ export const COOLDOWN_TIMERS = { export const CACHE_CONFIG = { BLOG_CACHE_TTL_MS: 24 * 60 * 60 * 1000, GIT_ACTIVITY_CACHE_TTL_MS: 10 * 60 * 1000, - BLOG_POSTS_LIST_CACHE_TTL_MS: 5 * 60 * 1000, + BLOG_POSTS_LIST_CACHE_TTL_MS: 15 * 60 * 1000, MAX_STALE_DATA_MS: 7 * 24 * 60 * 60 * 1000, GIT_ACTIVITY_MAX_STALE_MS: 24 * 60 * 60 * 1000 } as const; diff --git a/src/db/create.ts b/src/db/create.ts index dccd7b6..32ff508 100644 --- a/src/db/create.ts +++ b/src/db/create.ts @@ -155,6 +155,8 @@ export const model: { [key: string]: string } = { post_id INTEGER NOT NULL ); CREATE INDEX IF NOT EXISTS idx_tag_post_id ON Tag (post_id); + CREATE INDEX IF NOT EXISTS idx_tag_value ON Tag (value); + CREATE INDEX IF NOT EXISTS idx_tag_post_value ON Tag (post_id, value); `, PostHistory: ` CREATE TABLE PostHistory diff --git a/src/routes/account.tsx b/src/routes/account.tsx index ea1e95d..846688d 100644 --- a/src/routes/account.tsx +++ b/src/routes/account.tsx @@ -16,6 +16,7 @@ import PasswordInput from "~/components/ui/PasswordInput"; import Button from "~/components/ui/Button"; import FormFeedback from "~/components/ui/FormFeedback"; import type { UserProfile } from "~/types/user"; +import { useAuth } from "~/context/auth"; const getUserProfile = query(async (): Promise => { "use server"; @@ -27,13 +28,11 @@ const getUserProfile = query(async (): Promise => { throw redirect("/login"); } - const userId = userState.userId; - const conn = ConnectionFactory(); try { const res = await conn.execute({ - sql: "SELECT * FROM User WHERE id = ?", - args: [userId] + sql: "SELECT provider, image, password_hash FROM User WHERE id = ?", + args: [userState.userId] }); if (res.rows.length === 0) { @@ -43,10 +42,10 @@ const getUserProfile = query(async (): Promise => { const user = res.rows[0] as any; return { - id: user.id, - email: user.email ?? undefined, - emailVerified: user.email_verified === 1, - displayName: user.display_name ?? undefined, + id: userState.userId, + email: userState.email ?? undefined, + emailVerified: userState.emailVerified, + displayName: userState.displayName ?? undefined, provider: user.provider ?? undefined, image: user.image ?? undefined, hasPassword: !!user.password_hash @@ -63,6 +62,7 @@ export const route = { export default function AccountPage() { const navigate = useNavigate(); + const { refreshAuth } = useAuth(); const userData = createAsync(() => getUserProfile(), { deferStream: true }); @@ -451,6 +451,7 @@ export default function AccountPage() { setSignOutLoading(true); try { await api.auth.signOut.mutate(); + refreshAuth(); navigate("/"); } catch (error) { console.error("Sign out failed:", error); @@ -555,7 +556,11 @@ export default function AccountPage() { } >
- 💡 Add a password to enable email/password login + {!userProfile().email + ? "💡 Add and verify an email to enable email/password login" + : !userProfile().emailVerified + ? "💡 Verify your email to enable password setup" + : "💡 Add a password to enable email/password login"}
@@ -769,13 +774,50 @@ export default function AccountPage() { -
- {userProfile().provider === "email" - ? "Set a password to enable password login" - : "Add a password to enable email/password login alongside your " + - getProviderName(userProfile().provider) + - " login"} -
+ +
+
+ ⚠️ Email Verification Required +
+
+ {!userProfile().email + ? "Please add and verify an email address before setting a password." + : "Please verify your email address before setting a password."} +
+ + + +
+
+ +
+ {userProfile().provider === "email" + ? "Set a password to enable password login" + : "Add a password to enable email/password login alongside your " + + getProviderName(userProfile().provider) + + " login"} +
+
@@ -795,7 +837,13 @@ export default function AccountPage() { minlength="8" onInput={handleNewPasswordChange} onBlur={handlePasswordBlur} - disabled={passwordChangeLoading()} + disabled={ + passwordChangeLoading() || + (!userProfile().hasPassword && + userProfile().provider !== "email" && + (!userProfile().email || + !userProfile().emailVerified)) + } title="Password must be at least 8 characters" label="New Password" showStrength @@ -806,7 +854,13 @@ export default function AccountPage() { required minlength="8" onInput={handlePasswordConfChange} - disabled={passwordChangeLoading()} + disabled={ + passwordChangeLoading() || + (!userProfile().hasPassword && + userProfile().provider !== "email" && + (!userProfile().email || + !userProfile().emailVerified)) + } title="Password must be at least 8 characters" label="New Password Conf." /> @@ -828,7 +882,13 @@ export default function AccountPage() {