Spaces:
Sleeping
Sleeping
File size: 6,694 Bytes
42fe7da 8a95086 c42fdfa 8a95086 481feb4 f5fac5b 42fe7da f5fac5b 481feb4 08252f1 481feb4 8a95086 bc13e30 481feb4 08252f1 481feb4 b7b7391 481feb4 b7b7391 481feb4 cb6e939 481feb4 61dc592 42fe7da 481feb4 b7b7391 7b6a9d4 481feb4 b7b7391 481feb4 b7b7391 481feb4 2aaf97e 481feb4 b7b7391 481feb4 b7b7391 481feb4 b7b7391 481feb4 08252f1 481feb4 b7b7391 481feb4 b7b7391 08252f1 481feb4 b7b7391 bff24d2 b7b7391 c68b678 b7b7391 481feb4 bff24d2 481feb4 f5fac5b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | import React, { useMemo, useState } from 'react';
const LOGIC_SAYINGS = [
"Logic is disciplined honesty",
"Logic tames intuition",
"Logic survives scrutiny",
"Logic resists wishful thinking",
"Logic clarifies chaos",
"Logic enforces consistency",
"Logic demands consequences",
"Logic hates contradiction",
"Logic respects structure",
"Logic questions assumptions",
"Logic over loud opinions",
"Logic scales beyond intuition",
"Logic is structured doubt",
"Logic follows necessity",
"Logic earns trust",
"Logic trims nonsense",
"Logic values implication",
"Logic prevents self-deception",
"Logic is careful thinking",
"Logic disciplines belief",
"Logic outlives emotion",
"Logic defines fairness",
"Logic reveals errors",
"Logic needs no applause",
"Logic is patient clarity",
"Logic refuses shortcuts",
"Logic enforces coherence",
"Logic invites verification",
"Logic keeps promises",
"Logic respects evidence",
"Logic cuts cleanly",
"Logic exposes contradictions",
"Logic is structured reasoning",
"Logic defeats ambiguity",
"Logic rejects special pleading",
"Logic anchors truth",
"Logic strengthens arguments",
"Logic filters belief",
"Logic withstands pressure",
"Logic enables understanding",
"Logic is mental hygiene",
"Logic values consistency",
"Logic guards intelligence",
"Logic is intellectual integrity",
"Logic reveals necessity",
"Logic is consequence-aware",
"Logic clarifies premises",
"Logic enforces discipline",
"Logic refines thought",
"Logic avoids contradiction",
"Logic resists manipulation",
"Logic empowers truth",
"Logic disciplines intuition",
"Logic respects implication",
"Logic is rigorous thinking",
"Logic survives opposition",
"Logic rejects ambiguity",
"Logic is systematic clarity",
"Logic curbs bias",
"Logic anchors reasoning",
"Logic exposes fallacies",
"Logic enforces structure",
"Logic is formal honesty",
"Logic strengthens insight",
"Logic trims assumptions",
"Logic invites challenge",
"Logic prefers coherence",
"Logic defeats confusion",
"Logic remains impartial",
"Logic respects consequences",
"Logic makes sense durable",
"Logic tests belief",
"Logic values precision",
"Logic demands justification",
"Logic refines arguments",
"Logic guards truth",
"Logic stabilizes thought",
"Logic is disciplined skepticism",
"Logic clarifies meaning",
"Logic enforces necessity",
"Logic rejects contradictions",
"Logic sustains reasoning",
"Logic keeps ideas honest",
"Logic enforces fairness",
"Logic structures understanding",
"Logic prevents nonsense",
"Logic respects reality",
"Logic rejects inconsistency",
"Logic sharpens clarity",
"Logic enables precision",
"Logic stabilizes belief",
"Logic resists illusion",
"Logic enforces truthfulness",
"Logic exposes inconsistency",
"Logic refines clarity",
"Logic demands coherence",
"Logic preserves meaning",
"Logic strengthens truth",
"Logic clarifies necessity",
"Logic enforces rationality",
];
interface LoginProps {
onLogin: (
token: string,
user: { username: string; name: string }
) => void;
}
const Login: React.FC<LoginProps> = ({ onLogin }) => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const randomSaying = useMemo(
() => LOGIC_SAYINGS[Math.floor(Math.random() * LOGIC_SAYINGS.length)],
[]
);
const GATEWAY_URL = import.meta.env.VITE_GATEWAY_URL || 'https://deepthoughtai-evo-gateway.hf.space';
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError('');
setLoading(true);
try {
const endpoint = '/api/auth/login';
const body = { username, password };
const response = await fetch(`${GATEWAY_URL}${endpoint}`, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
let data: any = {};
const contentType = response.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
data = await response.json();
} else {
const text = await response.text();
data = { error: text || 'Authentication failed' };
}
if (!response.ok) {
throw new Error(data.error || 'Authentication failed');
}
const sessionId = data.token || '';
onLogin(sessionId, data.user);
} catch (err: any) {
setError(err.message || 'An error occurred');
} finally {
setLoading(false);
}
};
return (
<div className="login-page">
<div className="login-card">
<div className="login-brand">
<span className="login-logo">evo</span>
<p className="login-tagline">Logical AI</p>
</div>
<form onSubmit={handleSubmit} className="login-form">
<div className="form-field">
<label htmlFor="username">Username</label>
<input
id="username"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Enter username"
required
autoComplete="username"
autoFocus
/>
</div>
<div className="form-field">
<label htmlFor="password">Password</label>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Enter password"
required
autoComplete="current-password"
/>
</div>
{error && <div className="login-error">{error}</div>}
<button type="submit" className="login-submit-btn" disabled={loading}>
{loading ? 'Please wait...' : 'Sign In'}
</button>
</form>
<div className="login-saying">{randomSaying}</div>
<div style={{ textAlign: 'center', marginTop: '1rem' }}>
<a
href="https://machinelearning2014.github.io/"
target="_blank"
rel="noopener noreferrer"
style={{
color: '#2dd4bf',
fontSize: '0.82rem',
textDecoration: 'underline',
textUnderlineOffset: '2px',
}}
>
{"Don't have an account? Register"}
</a>
</div>
</div>
</div>
);
};
export default Login;
|