remove excess comments
This commit is contained in:
@@ -38,7 +38,6 @@ const getUserProfile = query(async (): Promise<UserProfile | null> => {
|
||||
|
||||
const user = res.rows[0] as any;
|
||||
|
||||
// Transform database User to UserProfile
|
||||
return {
|
||||
id: user.id,
|
||||
email: user.email ?? undefined,
|
||||
@@ -63,10 +62,8 @@ export default function AccountPage() {
|
||||
|
||||
const userData = createAsync(() => getUserProfile(), { deferStream: true });
|
||||
|
||||
// Local user state for client-side updates
|
||||
const [user, setUser] = createSignal<UserProfile | null>(null);
|
||||
|
||||
// Form loading states
|
||||
const [emailButtonLoading, setEmailButtonLoading] = createSignal(false);
|
||||
const [displayNameButtonLoading, setDisplayNameButtonLoading] =
|
||||
createSignal(false);
|
||||
@@ -76,7 +73,6 @@ export default function AccountPage() {
|
||||
const [profileImageSetLoading, setProfileImageSetLoading] =
|
||||
createSignal(false);
|
||||
|
||||
// Password state
|
||||
const [passwordsMatch, setPasswordsMatch] = createSignal(false);
|
||||
const [showPasswordLengthWarning, setShowPasswordLengthWarning] =
|
||||
createSignal(false);
|
||||
@@ -86,19 +82,16 @@ export default function AccountPage() {
|
||||
const [passwordError, setPasswordError] = createSignal(false);
|
||||
const [passwordDeletionError, setPasswordDeletionError] = createSignal(false);
|
||||
|
||||
// Show/hide password toggles
|
||||
const [showOldPasswordInput, setShowOldPasswordInput] = createSignal(false);
|
||||
const [showPasswordInput, setShowPasswordInput] = createSignal(false);
|
||||
const [showPasswordConfInput, setShowPasswordConfInput] = createSignal(false);
|
||||
|
||||
// Success messages
|
||||
const [showImageSuccess, setShowImageSuccess] = createSignal(false);
|
||||
const [showEmailSuccess, setShowEmailSuccess] = createSignal(false);
|
||||
const [showDisplayNameSuccess, setShowDisplayNameSuccess] =
|
||||
createSignal(false);
|
||||
const [showPasswordSuccess, setShowPasswordSuccess] = createSignal(false);
|
||||
|
||||
// Profile image state
|
||||
const [profileImage, setProfileImage] = createSignal<Blob | undefined>(
|
||||
undefined
|
||||
);
|
||||
@@ -109,7 +102,6 @@ export default function AccountPage() {
|
||||
createSignal(false);
|
||||
const [preSetHolder, setPreSetHolder] = createSignal<string | null>(null);
|
||||
|
||||
// Form refs
|
||||
let oldPasswordRef: HTMLInputElement | undefined;
|
||||
let newPasswordRef: HTMLInputElement | undefined;
|
||||
let newPasswordConfRef: HTMLInputElement | undefined;
|
||||
@@ -117,10 +109,8 @@ export default function AccountPage() {
|
||||
let displayNameRef: HTMLInputElement | undefined;
|
||||
let deleteAccountPasswordRef: HTMLInputElement | undefined;
|
||||
|
||||
// Helper to get current user (from SSR data or local state)
|
||||
const currentUser = () => user() || userData();
|
||||
|
||||
// Initialize preSetHolder when userData loads
|
||||
createEffect(() => {
|
||||
const userProfile = userData();
|
||||
if (userProfile?.image && !preSetHolder()) {
|
||||
@@ -308,7 +298,6 @@ export default function AccountPage() {
|
||||
if (response.ok && result.result?.data?.success) {
|
||||
setShowPasswordSuccess(true);
|
||||
setTimeout(() => setShowPasswordSuccess(false), 3000);
|
||||
// Clear form
|
||||
if (oldPasswordRef) oldPasswordRef.value = "";
|
||||
if (newPasswordRef) newPasswordRef.value = "";
|
||||
if (newPasswordConfRef) newPasswordConfRef.value = "";
|
||||
@@ -362,7 +351,6 @@ export default function AccountPage() {
|
||||
}
|
||||
setShowPasswordSuccess(true);
|
||||
setTimeout(() => setShowPasswordSuccess(false), 3000);
|
||||
// Clear form
|
||||
if (newPasswordRef) newPasswordRef.value = "";
|
||||
if (newPasswordConfRef) newPasswordConfRef.value = "";
|
||||
} else {
|
||||
@@ -395,7 +383,6 @@ export default function AccountPage() {
|
||||
|
||||
const result = await response.json();
|
||||
if (response.ok && result.result?.data?.success) {
|
||||
// Redirect to login
|
||||
navigate("/login");
|
||||
} else {
|
||||
setPasswordDeletionError(true);
|
||||
@@ -425,7 +412,6 @@ export default function AccountPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Password validation helpers
|
||||
const checkPasswordLength = (password: string) => {
|
||||
if (password.length >= 8) {
|
||||
setPasswordLengthSufficient(true);
|
||||
|
||||
@@ -7,7 +7,6 @@ export async function GET(event: APIEvent) {
|
||||
const code = url.searchParams.get("code");
|
||||
const error = url.searchParams.get("error");
|
||||
|
||||
// Handle OAuth error (user denied access, etc.)
|
||||
if (error) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
@@ -15,7 +14,6 @@ export async function GET(event: APIEvent) {
|
||||
});
|
||||
}
|
||||
|
||||
// Missing authorization code
|
||||
if (!code) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
@@ -32,13 +30,11 @@ export async function GET(event: APIEvent) {
|
||||
const result = await caller.auth.githubCallback({ code });
|
||||
|
||||
if (result.success) {
|
||||
// Redirect to account page on success
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: result.redirectTo || "/account" }
|
||||
});
|
||||
} else {
|
||||
// Redirect to login with error
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: "/login?error=auth_failed" }
|
||||
@@ -47,7 +43,6 @@ export async function GET(event: APIEvent) {
|
||||
} catch (error) {
|
||||
console.error("GitHub OAuth callback error:", error);
|
||||
|
||||
// Handle specific TRPC errors
|
||||
if (error && typeof error === "object" && "code" in error) {
|
||||
const trpcError = error as { code: string; message?: string };
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ export async function GET(event: APIEvent) {
|
||||
const code = url.searchParams.get("code");
|
||||
const error = url.searchParams.get("error");
|
||||
|
||||
// Handle OAuth error (user denied access, etc.)
|
||||
if (error) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
@@ -15,7 +14,6 @@ export async function GET(event: APIEvent) {
|
||||
});
|
||||
}
|
||||
|
||||
// Missing authorization code
|
||||
if (!code) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
@@ -32,13 +30,11 @@ export async function GET(event: APIEvent) {
|
||||
const result = await caller.auth.googleCallback({ code });
|
||||
|
||||
if (result.success) {
|
||||
// Redirect to account page on success
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: result.redirectTo || "/account" }
|
||||
});
|
||||
} else {
|
||||
// Redirect to login with error
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: "/login?error=auth_failed" }
|
||||
@@ -47,7 +43,6 @@ export async function GET(event: APIEvent) {
|
||||
} catch (error) {
|
||||
console.error("Google OAuth callback error:", error);
|
||||
|
||||
// Handle specific TRPC errors
|
||||
if (error && typeof error === "object" && "code" in error) {
|
||||
const trpcError = error as { code: string; message?: string };
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ export async function GET(event: APIEvent) {
|
||||
// Parse rememberMe parameter
|
||||
const rememberMe = rememberMeParam === "true";
|
||||
|
||||
// Missing required parameters
|
||||
if (!email || !token) {
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
@@ -32,13 +31,11 @@ export async function GET(event: APIEvent) {
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
// Redirect to account page on success
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: result.redirectTo || "/account" },
|
||||
});
|
||||
} else {
|
||||
// Redirect to login with error
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: { Location: "/login?error=auth_failed" },
|
||||
|
||||
@@ -7,7 +7,6 @@ export async function GET(event: APIEvent) {
|
||||
const email = url.searchParams.get("email");
|
||||
const token = url.searchParams.get("token");
|
||||
|
||||
// Missing required parameters
|
||||
if (!email || !token) {
|
||||
return new Response(
|
||||
`
|
||||
|
||||
@@ -15,7 +15,6 @@ export async function POST() {
|
||||
expires: new Date(0) // Set expiry to past date
|
||||
});
|
||||
|
||||
// Redirect to home page
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
headers: {
|
||||
|
||||
@@ -18,7 +18,6 @@ import type { Comment, CommentReaction, UserPublicData } from "~/types/comment";
|
||||
import { TerminalSplash } from "~/components/TerminalSplash";
|
||||
import { api } from "~/lib/api";
|
||||
|
||||
// Server function to fetch post by title
|
||||
const getPostByTitle = query(
|
||||
async (
|
||||
title: string,
|
||||
@@ -48,7 +47,6 @@ const getPostByTitle = query(
|
||||
const post = postResults.rows[0] as any;
|
||||
|
||||
if (!post) {
|
||||
// Check if post exists but is unpublished
|
||||
const existQuery = "SELECT id FROM Post WHERE title = ?";
|
||||
const existRes = await conn.execute({
|
||||
sql: existQuery,
|
||||
|
||||
@@ -8,7 +8,6 @@ import TagSelector from "~/components/blog/TagSelector";
|
||||
import PostSorting from "~/components/blog/PostSorting";
|
||||
import { TerminalSplash } from "~/components/TerminalSplash";
|
||||
|
||||
// Server function to fetch all posts
|
||||
const getPosts = query(async () => {
|
||||
"use server";
|
||||
const { ConnectionFactory, getPrivilegeLevel } =
|
||||
|
||||
@@ -40,7 +40,6 @@ const getContactData = query(async () => {
|
||||
return { remainingTime };
|
||||
}, "contact-data");
|
||||
|
||||
// Server action for form submission
|
||||
const sendContactEmail = action(async (formData: FormData) => {
|
||||
"use server";
|
||||
const name = formData.get("name") as string;
|
||||
@@ -65,7 +64,6 @@ const sendContactEmail = action(async (formData: FormData) => {
|
||||
);
|
||||
}
|
||||
|
||||
// Check rate limit
|
||||
const contactExp = getCookie("contactRequestSent");
|
||||
if (contactExp) {
|
||||
const expires = new Date(contactExp);
|
||||
@@ -189,7 +187,6 @@ export default function ContactPage() {
|
||||
setCountDown(serverData.remainingTime);
|
||||
}
|
||||
|
||||
// Check for existing timer
|
||||
const timer = getClientCookie("contactRequestSent");
|
||||
if (timer) {
|
||||
timerIdRef = setInterval(() => calcRemainder(timer), 1000);
|
||||
|
||||
@@ -42,7 +42,6 @@ export default function LoginPage() {
|
||||
const register = () => searchParams.mode === "register";
|
||||
const usePassword = () => searchParams.auth === "password";
|
||||
|
||||
// State management
|
||||
const [error, setError] = createSignal("");
|
||||
const [loading, setLoading] = createSignal(false);
|
||||
const [countDown, setCountDown] = createSignal(0);
|
||||
@@ -58,7 +57,6 @@ export default function LoginPage() {
|
||||
createSignal(false);
|
||||
const [passwordBlurred, setPasswordBlurred] = createSignal(false);
|
||||
|
||||
// Form refs
|
||||
let emailRef: HTMLInputElement | undefined;
|
||||
let passwordRef: HTMLInputElement | undefined;
|
||||
let passwordConfRef: HTMLInputElement | undefined;
|
||||
@@ -70,7 +68,6 @@ export default function LoginPage() {
|
||||
const githubClientId = env.VITE_GITHUB_CLIENT_ID;
|
||||
const domain = env.VITE_DOMAIN || "https://www.freno.me";
|
||||
|
||||
// Calculate remaining time from cookie
|
||||
const calcRemainder = (timer: string) => {
|
||||
const expires = new Date(timer);
|
||||
const remaining = expires.getTime() - Date.now();
|
||||
@@ -86,7 +83,6 @@ export default function LoginPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Check for existing timer on mount
|
||||
createEffect(() => {
|
||||
const timer = getClientCookie("emailLoginLinkRequested");
|
||||
if (timer) {
|
||||
@@ -103,7 +99,6 @@ export default function LoginPage() {
|
||||
});
|
||||
});
|
||||
|
||||
// Check for OAuth/callback errors in URL
|
||||
createEffect(() => {
|
||||
const errorParam = searchParams.error;
|
||||
if (errorParam) {
|
||||
@@ -121,7 +116,6 @@ export default function LoginPage() {
|
||||
}
|
||||
});
|
||||
|
||||
// Form submission handler
|
||||
const formHandler = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
@@ -273,7 +267,6 @@ export default function LoginPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Countdown timer render function
|
||||
const renderTime = ({ remainingTime }: { remainingTime: number }) => {
|
||||
return (
|
||||
<div class="timer">
|
||||
@@ -282,7 +275,6 @@ export default function LoginPage() {
|
||||
);
|
||||
};
|
||||
|
||||
// Password validation helpers
|
||||
const checkForMatch = (newPassword: string, newPasswordConf: string) => {
|
||||
setPasswordsMatch(newPassword === newPasswordConf);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@ export default function PasswordResetPage() {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
// State management
|
||||
const [passwordBlurred, setPasswordBlurred] = createSignal(false);
|
||||
const [passwordChangeLoading, setPasswordChangeLoading] = createSignal(false);
|
||||
const [passwordsMatch, setPasswordsMatch] = createSignal(false);
|
||||
@@ -25,21 +24,18 @@ export default function PasswordResetPage() {
|
||||
const [showPasswordInput, setShowPasswordInput] = createSignal(false);
|
||||
const [showPasswordConfInput, setShowPasswordConfInput] = createSignal(false);
|
||||
|
||||
// Form refs
|
||||
let newPasswordRef: HTMLInputElement | undefined;
|
||||
let newPasswordConfRef: HTMLInputElement | undefined;
|
||||
|
||||
// Get token from URL
|
||||
const token = searchParams.token;
|
||||
|
||||
// Redirect to request page if no token
|
||||
createEffect(() => {
|
||||
if (!token) {
|
||||
navigate("/login/request-password-reset");
|
||||
}
|
||||
});
|
||||
|
||||
// Form submission handler
|
||||
const setNewPasswordTrigger = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
setShowRequestNewEmail(false);
|
||||
@@ -93,7 +89,6 @@ export default function PasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Check if passwords match
|
||||
const checkForMatch = (newPassword: string, newPasswordConf: string) => {
|
||||
if (newPassword === newPasswordConf) {
|
||||
setPasswordsMatch(true);
|
||||
@@ -102,7 +97,6 @@ export default function PasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Check password length
|
||||
const checkPasswordLength = (password: string) => {
|
||||
if (password.length >= 8) {
|
||||
setPasswordLengthSufficient(true);
|
||||
@@ -115,7 +109,6 @@ export default function PasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle password blur
|
||||
const passwordLengthBlurCheck = () => {
|
||||
if (
|
||||
!passwordLengthSufficient() &&
|
||||
@@ -127,7 +120,6 @@ export default function PasswordResetPage() {
|
||||
setPasswordBlurred(true);
|
||||
};
|
||||
|
||||
// Handle new password change
|
||||
const handleNewPasswordChange = (e: Event) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
checkPasswordLength(target.value);
|
||||
@@ -136,7 +128,6 @@ export default function PasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle password confirmation change
|
||||
const handlePasswordConfChange = (e: Event) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
if (newPasswordRef) {
|
||||
@@ -144,7 +135,6 @@ export default function PasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle password blur
|
||||
const handlePasswordBlur = () => {
|
||||
passwordLengthBlurCheck();
|
||||
};
|
||||
|
||||
@@ -8,17 +8,14 @@ import { getClientCookie } from "~/lib/cookies.client";
|
||||
export default function RequestPasswordResetPage() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
// State management
|
||||
const [loading, setLoading] = createSignal(false);
|
||||
const [countDown, setCountDown] = createSignal(0);
|
||||
const [showSuccessMessage, setShowSuccessMessage] = createSignal(false);
|
||||
const [error, setError] = createSignal("");
|
||||
|
||||
// Form refs
|
||||
let emailRef: HTMLInputElement | undefined;
|
||||
let timerInterval: number | undefined;
|
||||
|
||||
// Calculate remaining time from cookie
|
||||
const calcRemainder = (timer: string) => {
|
||||
const expires = new Date(timer);
|
||||
const remaining = expires.getTime() - Date.now();
|
||||
@@ -34,7 +31,6 @@ export default function RequestPasswordResetPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Check for existing timer on mount
|
||||
createEffect(() => {
|
||||
const timer = getClientCookie("passwordResetRequested");
|
||||
if (timer) {
|
||||
@@ -51,7 +47,6 @@ export default function RequestPasswordResetPage() {
|
||||
});
|
||||
});
|
||||
|
||||
// Form submission handler
|
||||
const requestPasswordResetTrigger = async (e: Event) => {
|
||||
e.preventDefault();
|
||||
setError("");
|
||||
|
||||
Reference in New Issue
Block a user