Fix login and registration issues
Addresses issues preventing successful login and registration.
This commit is contained in:
@@ -4,7 +4,7 @@ import { Link } from "react-router-dom";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ArrowRight, Mail, KeyRound, Eye, EyeOff, AlertTriangle, Loader2 } from "lucide-react";
|
||||
import { ArrowRight, Mail, KeyRound, Eye, EyeOff, AlertTriangle, Loader2, WifiOff } from "lucide-react";
|
||||
|
||||
interface LoginFormProps {
|
||||
email: string;
|
||||
@@ -17,6 +17,8 @@ interface LoginFormProps {
|
||||
isSettingUpTables?: boolean;
|
||||
loginError: string | null;
|
||||
handleLogin: (e: React.FormEvent) => Promise<void>;
|
||||
isOfflineMode?: boolean;
|
||||
setIsOfflineMode?: (offline: boolean) => void;
|
||||
}
|
||||
|
||||
const LoginForm: React.FC<LoginFormProps> = ({
|
||||
@@ -29,12 +31,23 @@ const LoginForm: React.FC<LoginFormProps> = ({
|
||||
isLoading,
|
||||
isSettingUpTables = false,
|
||||
loginError,
|
||||
handleLogin
|
||||
handleLogin,
|
||||
isOfflineMode = false,
|
||||
setIsOfflineMode
|
||||
}) => {
|
||||
// CORS 또는 JSON 관련 오류인지 확인
|
||||
const isCorsOrJsonError = loginError &&
|
||||
(loginError.includes('JSON') || loginError.includes('CORS') ||
|
||||
loginError.includes('프록시') || loginError.includes('서버 응답'));
|
||||
loginError.includes('프록시') || loginError.includes('서버 응답') ||
|
||||
loginError.includes('네트워크'));
|
||||
|
||||
const toggleOfflineMode = () => {
|
||||
if (setIsOfflineMode) {
|
||||
const newMode = !isOfflineMode;
|
||||
setIsOfflineMode(newMode);
|
||||
localStorage.setItem('offline_mode', newMode.toString());
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="neuro-flat p-8 mb-6">
|
||||
@@ -89,6 +102,13 @@ const LoginForm: React.FC<LoginFormProps> = ({
|
||||
<li>설정 페이지에서 다른 CORS 프록시 유형을 시도해 보세요.</li>
|
||||
<li>HTTPS URL을 사용하는 Supabase 인스턴스로 변경해 보세요.</li>
|
||||
<li>네트워크 연결 상태를 확인하세요.</li>
|
||||
<li><button
|
||||
type="button"
|
||||
onClick={toggleOfflineMode}
|
||||
className="text-neuro-income hover:underline inline-flex items-center"
|
||||
>
|
||||
<WifiOff className="h-3 w-3 mr-1" /> 오프라인 모드로 전환하기
|
||||
</button></li>
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
@@ -96,6 +116,25 @@ const LoginForm: React.FC<LoginFormProps> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isOfflineMode && (
|
||||
<div className="p-3 bg-blue-50 text-blue-800 rounded-md text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<WifiOff className="h-5 w-5 text-blue-500" />
|
||||
<div>
|
||||
<p className="font-medium">오프라인 모드 활성화됨</p>
|
||||
<p className="text-xs mt-1">서버 없이 앱의 기본 기능을 사용할 수 있습니다. 데이터는 로컬에 저장됩니다.</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggleOfflineMode}
|
||||
className="text-neuro-income hover:underline text-xs mt-1"
|
||||
>
|
||||
온라인 모드로 전환
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="text-right">
|
||||
<Link to="/forgot-password" className="text-sm text-neuro-income hover:underline">
|
||||
비밀번호를 잊으셨나요?
|
||||
@@ -108,7 +147,8 @@ const LoginForm: React.FC<LoginFormProps> = ({
|
||||
className="w-full hover:bg-neuro-income/80 text-white py-6 h-auto bg-neuro-income"
|
||||
>
|
||||
{isLoading ? "로그인 중..." :
|
||||
isSettingUpTables ? "데이터베이스 설정 중..." : "로그인"}
|
||||
isSettingUpTables ? "데이터베이스 설정 중..." :
|
||||
isOfflineMode ? "오프라인 모드로 로그인" : "로그인"}
|
||||
{!isLoading && !isSettingUpTables ?
|
||||
<ArrowRight className="ml-2 h-5 w-5" /> :
|
||||
<Loader2 className="ml-2 h-5 w-5 animate-spin" />}
|
||||
|
||||
Reference in New Issue
Block a user