This commit is contained in:
eric
2026-03-26 10:57:26 -05:00
parent a94e801a95
commit eaa92ddf36
3 changed files with 171 additions and 36 deletions

View File

@@ -28,6 +28,15 @@ export function LoginForm({
const [error, setError] = useState<string | null>(null);
const inputRef = useRef<HTMLInputElement>(null);
const getCandidateUserId = (): string => {
if (typeof window === "undefined") return "";
const fromMemos = localStorage.getItem("memosAccount")?.trim() || "";
if (/^user\d+$/.test(fromMemos)) return fromMemos;
const fromUserId = localStorage.getItem("userId")?.trim() || "";
if (/^user\d+$/.test(fromUserId)) return fromUserId;
return "";
};
useEffect(() => {
if (autoFocus) inputRef.current?.focus();
}, [autoFocus, mode]);
@@ -71,7 +80,12 @@ export function LoginForm({
setError(null);
setLoading(true);
try {
const result = await onVerifyByEmail(trimmedEmail, trimmedPassword);
const candidateUserId = getCandidateUserId();
const result = await onVerifyByEmail(
trimmedEmail,
trimmedPassword,
candidateUserId || undefined
);
const ok = typeof result === "object" ? result.ok : result;
const errMsg = typeof result === "object" ? result.error : undefined;
if (ok) onSuccess();