's'
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user