fix(web):update password auth forms

This commit is contained in:
Anish Sarkar 2026-06-23 12:58:25 +05:30
parent 71045e552d
commit 1163557453
2 changed files with 6 additions and 5 deletions

View file

@ -38,7 +38,7 @@ export function LocalLoginForm() {
trackLoginAttempt("local");
try {
const data = await login({
await login({
username,
password,
grant_type: "password",
@ -54,7 +54,7 @@ export function LocalLoginForm() {
// Small delay to show success message
setTimeout(() => {
router.push(`/auth/callback?token=${data.access_token}`);
router.push("/auth/callback");
}, 500);
} catch (err) {
if (err instanceof ValidationError) {

View file

@ -12,8 +12,8 @@ import { Logo } from "@/components/Logo";
import { useRuntimeConfig } from "@/components/providers/runtime-config";
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { useSession } from "@/hooks/use-session";
import { getAuthErrorDetails, isNetworkError, shouldRetry } from "@/lib/auth-errors";
import { getBearerToken } from "@/lib/auth-utils";
import { AppError, ValidationError } from "@/lib/error";
import {
trackRegistrationAttempt,
@ -37,18 +37,19 @@ export default function RegisterPage() {
message: null,
});
const router = useRouter();
const session = useSession();
const [{ mutateAsync: register, isPending: isRegistering }] = useAtom(registerMutationAtom);
// Check authentication type and redirect if not LOCAL
useEffect(() => {
if (getBearerToken()) {
if (session.status === "authenticated") {
router.replace("/dashboard");
return;
}
if (authType !== "LOCAL") {
router.push("/login");
}
}, [authType, router]);
}, [authType, router, session.status]);
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();