ltcai 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/package.json +3 -3
- package/requirements.txt +1 -0
- package/server.py +167 -18
- package/static/account.html +509 -0
- package/static/admin.html +214 -67
- package/static/{indexd.html → chat.html} +299 -124
- package/static/index.html +0 -270
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="ko">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Lattice AI</title>
|
|
7
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css">
|
|
8
|
+
<style>
|
|
9
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
|
|
10
|
+
|
|
11
|
+
:root {
|
|
12
|
+
--bg: #080c0a;
|
|
13
|
+
--text: #f3f1e8;
|
|
14
|
+
--faint: #7c8078;
|
|
15
|
+
--accent: #22d3a0;
|
|
16
|
+
--shadow: 0 24px 70px rgba(0,0,0,0.5);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
20
|
+
html, body { height: 100%; }
|
|
21
|
+
body {
|
|
22
|
+
font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
23
|
+
color: var(--text);
|
|
24
|
+
background:
|
|
25
|
+
linear-gradient(180deg, rgba(255,255,255,0.012), transparent 28%),
|
|
26
|
+
linear-gradient(135deg, #080c0a 0%, #060a08 52%, #0a0d09 100%);
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
padding: 24px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
position: relative;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body::before {
|
|
37
|
+
content: '';
|
|
38
|
+
position: fixed;
|
|
39
|
+
inset: 0;
|
|
40
|
+
background:
|
|
41
|
+
linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
|
|
42
|
+
linear-gradient(90deg, rgba(255,255,255,0.016) 1px, transparent 1px);
|
|
43
|
+
background-size: 44px 44px;
|
|
44
|
+
mask-image: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.06));
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
body::after {
|
|
49
|
+
content: '';
|
|
50
|
+
position: fixed;
|
|
51
|
+
inset: 0;
|
|
52
|
+
background:
|
|
53
|
+
radial-gradient(ellipse 70% 60% at 18% 18%, rgba(34,211,160,0.16) 0%, transparent 55%),
|
|
54
|
+
radial-gradient(ellipse 55% 50% at 82% 82%, rgba(129,140,248,0.13) 0%, transparent 55%);
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.orb {
|
|
59
|
+
position: fixed;
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
filter: blur(70px);
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
}
|
|
64
|
+
.orb-1 { width: 440px; height: 440px; top: -170px; left: -120px; background: rgba(34,211,160,0.13); }
|
|
65
|
+
.orb-2 { width: 380px; height: 380px; bottom: -130px; right: -90px; background: rgba(129,140,248,0.11); }
|
|
66
|
+
|
|
67
|
+
.card {
|
|
68
|
+
width: min(400px, 100%);
|
|
69
|
+
background: rgba(10,14,12,0.88);
|
|
70
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
71
|
+
border-radius: 22px;
|
|
72
|
+
padding: 38px 34px;
|
|
73
|
+
box-shadow: var(--shadow), 0 0 0 1px rgba(34,211,160,0.05);
|
|
74
|
+
position: relative;
|
|
75
|
+
z-index: 1;
|
|
76
|
+
backdrop-filter: blur(28px);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.card::before {
|
|
80
|
+
content: '';
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: 0; left: 50%;
|
|
83
|
+
transform: translateX(-50%);
|
|
84
|
+
width: 55%; height: 1px;
|
|
85
|
+
background: linear-gradient(90deg, transparent, rgba(34,211,160,0.55), transparent);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.logo {
|
|
89
|
+
width: 54px; height: 54px;
|
|
90
|
+
background: linear-gradient(135deg, #22d3a0, #818cf8);
|
|
91
|
+
border-radius: 15px;
|
|
92
|
+
display: flex; align-items: center; justify-content: center;
|
|
93
|
+
font-size: 26px; color: #040706;
|
|
94
|
+
margin: 0 auto 18px;
|
|
95
|
+
box-shadow: 0 0 32px rgba(34,211,160,0.32), 0 8px 24px rgba(0,0,0,0.4);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.title {
|
|
99
|
+
text-align: center;
|
|
100
|
+
font-size: 23px;
|
|
101
|
+
font-weight: 800;
|
|
102
|
+
margin-bottom: 6px;
|
|
103
|
+
background: linear-gradient(135deg, #fff 40%, rgba(34,211,160,0.9));
|
|
104
|
+
-webkit-background-clip: text;
|
|
105
|
+
-webkit-text-fill-color: transparent;
|
|
106
|
+
background-clip: text;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.subtitle {
|
|
110
|
+
text-align: center;
|
|
111
|
+
color: var(--faint);
|
|
112
|
+
font-size: 12.5px;
|
|
113
|
+
margin-bottom: 26px;
|
|
114
|
+
line-height: 1.5;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.input {
|
|
118
|
+
width: 100%;
|
|
119
|
+
padding: 12px 14px;
|
|
120
|
+
margin-bottom: 10px;
|
|
121
|
+
background: rgba(255,255,255,0.04);
|
|
122
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
123
|
+
color: var(--text);
|
|
124
|
+
border-radius: 10px;
|
|
125
|
+
outline: none;
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
font-family: inherit;
|
|
128
|
+
transition: border-color .15s, box-shadow .15s;
|
|
129
|
+
}
|
|
130
|
+
.input:focus {
|
|
131
|
+
border-color: rgba(34,211,160,0.5);
|
|
132
|
+
box-shadow: 0 0 0 3px rgba(34,211,160,0.08);
|
|
133
|
+
}
|
|
134
|
+
.input::placeholder { color: var(--faint); }
|
|
135
|
+
|
|
136
|
+
.submit {
|
|
137
|
+
width: 100%;
|
|
138
|
+
padding: 13px;
|
|
139
|
+
background: linear-gradient(135deg, #22d3a0, #1ab88c);
|
|
140
|
+
color: #030d09;
|
|
141
|
+
border: none;
|
|
142
|
+
border-radius: 10px;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
font-weight: 800;
|
|
145
|
+
font-size: 14px;
|
|
146
|
+
font-family: inherit;
|
|
147
|
+
box-shadow: 0 0 20px rgba(34,211,160,0.28), 0 4px 12px rgba(0,0,0,0.3);
|
|
148
|
+
transition: all .18s;
|
|
149
|
+
margin-top: 4px;
|
|
150
|
+
}
|
|
151
|
+
.submit:hover {
|
|
152
|
+
background: linear-gradient(135deg, #2de8b0, #22d3a0);
|
|
153
|
+
box-shadow: 0 0 30px rgba(34,211,160,0.38), 0 4px 14px rgba(0,0,0,0.3);
|
|
154
|
+
transform: translateY(-1px);
|
|
155
|
+
}
|
|
156
|
+
.submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
|
|
157
|
+
|
|
158
|
+
.switch {
|
|
159
|
+
margin-top: 18px;
|
|
160
|
+
text-align: center;
|
|
161
|
+
font-size: 12.5px;
|
|
162
|
+
color: var(--faint);
|
|
163
|
+
}
|
|
164
|
+
.switch a { color: var(--accent); text-decoration: none; font-weight: 700; }
|
|
165
|
+
.switch a:hover { text-decoration: underline; }
|
|
166
|
+
|
|
167
|
+
.sso-divider {
|
|
168
|
+
display: flex; align-items: center; gap: 10px;
|
|
169
|
+
margin: 14px 0 10px;
|
|
170
|
+
color: var(--faint); font-size: 11.5px;
|
|
171
|
+
}
|
|
172
|
+
.sso-divider::before, .sso-divider::after {
|
|
173
|
+
content: ''; flex: 1;
|
|
174
|
+
height: 1px; background: rgba(255,255,255,0.07);
|
|
175
|
+
}
|
|
176
|
+
.sso-btn {
|
|
177
|
+
width: 100%;
|
|
178
|
+
padding: 12px;
|
|
179
|
+
background: rgba(255,255,255,0.04);
|
|
180
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
181
|
+
color: var(--text);
|
|
182
|
+
border-radius: 10px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
font-weight: 600;
|
|
185
|
+
font-size: 13.5px;
|
|
186
|
+
font-family: inherit;
|
|
187
|
+
display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
188
|
+
transition: all .18s;
|
|
189
|
+
}
|
|
190
|
+
.sso-btn:hover {
|
|
191
|
+
background: rgba(255,255,255,0.08);
|
|
192
|
+
border-color: rgba(34,211,160,0.3);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.msg {
|
|
196
|
+
font-size: 12px;
|
|
197
|
+
min-height: 18px;
|
|
198
|
+
margin-bottom: 6px;
|
|
199
|
+
text-align: center;
|
|
200
|
+
color: #ffbdb8;
|
|
201
|
+
}
|
|
202
|
+
.msg.ok { color: #9be7cd; }
|
|
203
|
+
|
|
204
|
+
/* Lang picker */
|
|
205
|
+
.lang-wrap {
|
|
206
|
+
position: fixed;
|
|
207
|
+
top: 20px;
|
|
208
|
+
right: 24px;
|
|
209
|
+
z-index: 10;
|
|
210
|
+
}
|
|
211
|
+
.lang-btn {
|
|
212
|
+
background: rgba(255,255,255,0.05);
|
|
213
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
214
|
+
color: var(--text);
|
|
215
|
+
border-radius: 8px;
|
|
216
|
+
padding: 7px 12px;
|
|
217
|
+
font-size: 13px;
|
|
218
|
+
font-family: inherit;
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
transition: background .15s;
|
|
221
|
+
}
|
|
222
|
+
.lang-btn:hover { background: rgba(255,255,255,0.1); }
|
|
223
|
+
.lang-menu {
|
|
224
|
+
display: none;
|
|
225
|
+
position: absolute;
|
|
226
|
+
top: calc(100% + 6px);
|
|
227
|
+
right: 0;
|
|
228
|
+
background: #141a16;
|
|
229
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
230
|
+
border-radius: 10px;
|
|
231
|
+
padding: 4px;
|
|
232
|
+
min-width: 130px;
|
|
233
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
|
234
|
+
}
|
|
235
|
+
.lang-menu.open { display: block; }
|
|
236
|
+
.lang-opt {
|
|
237
|
+
padding: 7px 10px;
|
|
238
|
+
border-radius: 7px;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
font-size: 13px;
|
|
241
|
+
color: var(--faint);
|
|
242
|
+
}
|
|
243
|
+
.lang-opt:hover { background: rgba(255,255,255,0.06); color: var(--text); }
|
|
244
|
+
.lang-opt.active { color: var(--accent); font-weight: 700; }
|
|
245
|
+
</style>
|
|
246
|
+
</head>
|
|
247
|
+
<body>
|
|
248
|
+
<div class="orb orb-1"></div>
|
|
249
|
+
<div class="orb orb-2"></div>
|
|
250
|
+
|
|
251
|
+
<div class="lang-wrap">
|
|
252
|
+
<button class="lang-btn" id="lang-btn" onclick="toggleLang()">🌐 <span id="lang-label">한국어</span></button>
|
|
253
|
+
<div class="lang-menu" id="lang-menu">
|
|
254
|
+
<div class="lang-opt" id="opt-ko" onclick="setLang('ko')">🇰🇷 한국어</div>
|
|
255
|
+
<div class="lang-opt" id="opt-en" onclick="setLang('en')">🇺🇸 English</div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div class="card">
|
|
260
|
+
<!-- Login form -->
|
|
261
|
+
<div id="login-section">
|
|
262
|
+
<div class="logo"><i class="ti ti-brain"></i></div>
|
|
263
|
+
<h2 class="title" id="login-title">Lattice AI</h2>
|
|
264
|
+
<p class="subtitle" id="login-sub">Local AI Workspace — Apple Silicon</p>
|
|
265
|
+
<input class="input" type="email" id="login-email" placeholder="이메일 주소">
|
|
266
|
+
<input class="input" type="password" id="login-pw" placeholder="비밀번호" onkeydown="if(event.key==='Enter')doLogin()">
|
|
267
|
+
<div class="msg" id="login-msg"></div>
|
|
268
|
+
<button class="submit" id="login-btn" onclick="doLogin()" data-ko="로그인" data-en="Log in">로그인</button>
|
|
269
|
+
<div id="sso-section" style="display:none;">
|
|
270
|
+
<div class="sso-divider" id="sso-divider-text">또는</div>
|
|
271
|
+
<button class="sso-btn" id="sso-btn" onclick="doSSOLogin()">
|
|
272
|
+
<i class="ti ti-building"></i>
|
|
273
|
+
<span id="sso-btn-label">SSO로 로그인</span>
|
|
274
|
+
</button>
|
|
275
|
+
</div>
|
|
276
|
+
<p class="switch" id="login-switch">
|
|
277
|
+
<span id="no-account-text">계정이 없으신가요?</span>
|
|
278
|
+
<a href="#" onclick="showSection('register');return false;" id="go-register-link">회원가입</a>
|
|
279
|
+
</p>
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
<!-- Register form -->
|
|
283
|
+
<div id="register-section" style="display:none;">
|
|
284
|
+
<div class="logo"><i class="ti ti-user-plus"></i></div>
|
|
285
|
+
<h2 class="title" id="reg-title">계정 만들기</h2>
|
|
286
|
+
<p class="subtitle" id="reg-sub">Lattice AI 워크스페이스에 참여하세요</p>
|
|
287
|
+
<input class="input" type="email" id="reg-email" placeholder="이메일 주소">
|
|
288
|
+
<input class="input" type="password" id="reg-pw" placeholder="비밀번호 (4자 이상)">
|
|
289
|
+
<input class="input" type="password" id="reg-pw2" placeholder="비밀번호 확인">
|
|
290
|
+
<input class="input" type="text" id="reg-name" placeholder="이름">
|
|
291
|
+
<input class="input" type="text" id="reg-nick" placeholder="닉네임">
|
|
292
|
+
<div class="msg" id="reg-msg"></div>
|
|
293
|
+
<button class="submit" id="reg-btn" onclick="doRegister()">가입하기</button>
|
|
294
|
+
<p class="switch" id="reg-switch">
|
|
295
|
+
<span id="have-account-text">이미 계정이 있나요?</span>
|
|
296
|
+
<a href="#" onclick="showSection('login');return false;" id="go-login-link">로그인</a>
|
|
297
|
+
</p>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<script>
|
|
302
|
+
const API_BASE = window.location.protocol === 'file:' ? 'http://localhost:4825' : '';
|
|
303
|
+
function apiFetch(path, opts = {}) { return fetch(API_BASE + path, opts); }
|
|
304
|
+
|
|
305
|
+
// ── i18n ──────────────────────────────────────────────
|
|
306
|
+
const I18N = {
|
|
307
|
+
ko: {
|
|
308
|
+
login_title: 'Lattice AI', login_sub: 'Local AI Workspace — Apple Silicon',
|
|
309
|
+
ph_email: '이메일 주소', ph_pw: '비밀번호', ph_new_pw: '비밀번호 (4자 이상)',
|
|
310
|
+
ph_pw_confirm: '비밀번호 확인', ph_name: '이름', ph_nick: '닉네임',
|
|
311
|
+
btn_login: '로그인', btn_register: '가입하기',
|
|
312
|
+
no_account: '계정이 없으신가요?', go_register: '회원가입',
|
|
313
|
+
have_account: '이미 계정이 있나요?', go_login: '로그인',
|
|
314
|
+
reg_title: '계정 만들기', reg_sub: 'Lattice AI 워크스페이스에 참여하세요',
|
|
315
|
+
err_pw_mismatch: '비밀번호가 일치하지 않습니다.',
|
|
316
|
+
err_fill: '모든 항목을 입력해주세요.',
|
|
317
|
+
err_login_fail: '이메일 또는 비밀번호가 틀렸습니다.',
|
|
318
|
+
err_server: '서버 연결 실패',
|
|
319
|
+
sso_divider: '또는', sso_btn: '로 로그인',
|
|
320
|
+
},
|
|
321
|
+
en: {
|
|
322
|
+
login_title: 'Lattice AI', login_sub: 'Local AI Workspace — Apple Silicon',
|
|
323
|
+
ph_email: 'Email address', ph_pw: 'Password', ph_new_pw: 'Password (min. 4 chars)',
|
|
324
|
+
ph_pw_confirm: 'Confirm password', ph_name: 'Full name', ph_nick: 'Nickname',
|
|
325
|
+
btn_login: 'Log in', btn_register: 'Sign up',
|
|
326
|
+
no_account: "Don't have an account?", go_register: 'Sign up',
|
|
327
|
+
have_account: 'Already have an account?', go_login: 'Log in',
|
|
328
|
+
reg_title: 'Create Account', reg_sub: 'Join the Lattice AI workspace',
|
|
329
|
+
err_pw_mismatch: 'Passwords do not match.',
|
|
330
|
+
err_fill: 'Please fill in all fields.',
|
|
331
|
+
err_login_fail: 'Invalid email or password.',
|
|
332
|
+
err_server: 'Server connection failed',
|
|
333
|
+
sso_divider: 'or', sso_btn: 'Sign in with',
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
let lang = localStorage.getItem('ltcai_lang') || 'ko';
|
|
338
|
+
function t(k) { return (I18N[lang] || I18N.ko)[k] || k; }
|
|
339
|
+
|
|
340
|
+
function applyI18n() {
|
|
341
|
+
document.getElementById('login-title').textContent = t('login_title');
|
|
342
|
+
document.getElementById('login-sub').textContent = t('login_sub');
|
|
343
|
+
document.getElementById('reg-title').textContent = t('reg_title');
|
|
344
|
+
document.getElementById('reg-sub').textContent = t('reg_sub');
|
|
345
|
+
document.getElementById('login-btn').textContent = t('btn_login');
|
|
346
|
+
document.getElementById('reg-btn').textContent = t('btn_register');
|
|
347
|
+
document.getElementById('no-account-text').textContent = t('no_account');
|
|
348
|
+
document.getElementById('go-register-link').textContent = t('go_register');
|
|
349
|
+
document.getElementById('have-account-text').textContent = t('have_account');
|
|
350
|
+
document.getElementById('go-login-link').textContent = t('go_login');
|
|
351
|
+
document.getElementById('login-email').placeholder = t('ph_email');
|
|
352
|
+
document.getElementById('login-pw').placeholder = t('ph_pw');
|
|
353
|
+
document.getElementById('reg-email').placeholder = t('ph_email');
|
|
354
|
+
document.getElementById('reg-pw').placeholder = t('ph_new_pw');
|
|
355
|
+
document.getElementById('reg-pw2').placeholder = t('ph_pw_confirm');
|
|
356
|
+
document.getElementById('reg-name').placeholder = t('ph_name');
|
|
357
|
+
document.getElementById('reg-nick').placeholder = t('ph_nick');
|
|
358
|
+
document.getElementById('lang-label').textContent = lang === 'ko' ? '한국어' : 'English';
|
|
359
|
+
document.getElementById('sso-divider-text').textContent = t('sso_divider');
|
|
360
|
+
const ssoName = window._ssoProviderName || 'SSO';
|
|
361
|
+
document.getElementById('sso-btn-label').textContent =
|
|
362
|
+
lang === 'ko' ? `${ssoName}${t('sso_btn')}` : `${t('sso_btn')} ${ssoName}`;
|
|
363
|
+
['ko', 'en'].forEach(l => {
|
|
364
|
+
const el = document.getElementById(`opt-${l}`);
|
|
365
|
+
if (el) el.classList.toggle('active', l === lang);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
async function initSSO() {
|
|
370
|
+
try {
|
|
371
|
+
const res = await apiFetch('/auth/sso/config');
|
|
372
|
+
if (!res.ok) return;
|
|
373
|
+
const cfg = await res.json();
|
|
374
|
+
if (cfg.enabled) {
|
|
375
|
+
window._ssoProviderName = cfg.provider_name;
|
|
376
|
+
document.getElementById('sso-section').style.display = '';
|
|
377
|
+
applyI18n();
|
|
378
|
+
}
|
|
379
|
+
} catch {}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function doSSOLogin() {
|
|
383
|
+
window.location.href = '/auth/sso/login';
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function toggleLang() {
|
|
387
|
+
const m = document.getElementById('lang-menu');
|
|
388
|
+
m.classList.toggle('open');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function setLang(l) {
|
|
392
|
+
lang = l;
|
|
393
|
+
localStorage.setItem('ltcai_lang', l);
|
|
394
|
+
document.getElementById('lang-menu').classList.remove('open');
|
|
395
|
+
applyI18n();
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
document.addEventListener('click', e => {
|
|
399
|
+
if (!e.target.closest('.lang-wrap'))
|
|
400
|
+
document.getElementById('lang-menu').classList.remove('open');
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
function showSection(name) {
|
|
404
|
+
document.getElementById('login-section').style.display = name === 'login' ? '' : 'none';
|
|
405
|
+
document.getElementById('register-section').style.display = name === 'register' ? '' : 'none';
|
|
406
|
+
document.getElementById('login-msg').textContent = '';
|
|
407
|
+
document.getElementById('reg-msg').textContent = '';
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function setMsg(id, text, ok = false) {
|
|
411
|
+
const el = document.getElementById(id);
|
|
412
|
+
el.textContent = text;
|
|
413
|
+
el.className = 'msg' + (ok ? ' ok' : '');
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async function doLogin() {
|
|
417
|
+
const email = document.getElementById('login-email').value.trim();
|
|
418
|
+
const password = document.getElementById('login-pw').value;
|
|
419
|
+
if (!email || !password) { setMsg('login-msg', t('err_fill')); return; }
|
|
420
|
+
const btn = document.getElementById('login-btn');
|
|
421
|
+
btn.disabled = true;
|
|
422
|
+
btn.textContent = '...';
|
|
423
|
+
try {
|
|
424
|
+
const res = await apiFetch('/login', {
|
|
425
|
+
method: 'POST',
|
|
426
|
+
headers: { 'Content-Type': 'application/json' },
|
|
427
|
+
body: JSON.stringify({ email, password })
|
|
428
|
+
});
|
|
429
|
+
if (res.ok) {
|
|
430
|
+
const data = await res.json();
|
|
431
|
+
localStorage.setItem('ltcai_user_email', data.email);
|
|
432
|
+
localStorage.setItem('ltcai_user_nickname', data.nickname || data.name || data.email);
|
|
433
|
+
localStorage.setItem('ltcai_is_admin', data.is_admin ? 'true' : 'false');
|
|
434
|
+
window.location.href = '/chat';
|
|
435
|
+
} else {
|
|
436
|
+
const data = await res.json().catch(() => ({}));
|
|
437
|
+
setMsg('login-msg', data.detail || t('err_login_fail'));
|
|
438
|
+
btn.disabled = false;
|
|
439
|
+
btn.textContent = t('btn_login');
|
|
440
|
+
}
|
|
441
|
+
} catch {
|
|
442
|
+
setMsg('login-msg', t('err_server'));
|
|
443
|
+
btn.disabled = false;
|
|
444
|
+
btn.textContent = t('btn_login');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
async function doRegister() {
|
|
449
|
+
const email = document.getElementById('reg-email').value.trim();
|
|
450
|
+
const pw = document.getElementById('reg-pw').value;
|
|
451
|
+
const pw2 = document.getElementById('reg-pw2').value;
|
|
452
|
+
const name = document.getElementById('reg-name').value.trim();
|
|
453
|
+
const nickname = document.getElementById('reg-nick').value.trim();
|
|
454
|
+
if (!email || !pw || !name || !nickname) { setMsg('reg-msg', t('err_fill')); return; }
|
|
455
|
+
if (pw !== pw2) { setMsg('reg-msg', t('err_pw_mismatch')); return; }
|
|
456
|
+
const btn = document.getElementById('reg-btn');
|
|
457
|
+
btn.disabled = true;
|
|
458
|
+
btn.textContent = '...';
|
|
459
|
+
try {
|
|
460
|
+
const res = await apiFetch('/register', {
|
|
461
|
+
method: 'POST',
|
|
462
|
+
headers: { 'Content-Type': 'application/json' },
|
|
463
|
+
body: JSON.stringify({ email, password: pw, name, nickname })
|
|
464
|
+
});
|
|
465
|
+
if (res.ok) {
|
|
466
|
+
setMsg('reg-msg', lang === 'ko' ? '가입 완료! 로그인 중...' : 'Registered! Logging in...', true);
|
|
467
|
+
await apiFetch('/login', {
|
|
468
|
+
method: 'POST',
|
|
469
|
+
headers: { 'Content-Type': 'application/json' },
|
|
470
|
+
body: JSON.stringify({ email, password: pw })
|
|
471
|
+
}).then(r => r.ok ? r.json() : null).then(data => {
|
|
472
|
+
if (data) {
|
|
473
|
+
localStorage.setItem('ltcai_user_email', data.email);
|
|
474
|
+
localStorage.setItem('ltcai_user_nickname', data.nickname || data.name || data.email);
|
|
475
|
+
localStorage.setItem('ltcai_is_admin', data.is_admin ? 'true' : 'false');
|
|
476
|
+
window.location.href = '/chat';
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
} else {
|
|
480
|
+
const data = await res.json().catch(() => ({}));
|
|
481
|
+
setMsg('reg-msg', data.detail || '가입 실패');
|
|
482
|
+
btn.disabled = false;
|
|
483
|
+
btn.textContent = t('btn_register');
|
|
484
|
+
}
|
|
485
|
+
} catch {
|
|
486
|
+
setMsg('reg-msg', t('err_server'));
|
|
487
|
+
btn.disabled = false;
|
|
488
|
+
btn.textContent = t('btn_register');
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// If already logged in, skip to chat
|
|
493
|
+
apiFetch('/account/profile').then(r => {
|
|
494
|
+
if (r.ok) window.location.href = '/chat';
|
|
495
|
+
}).catch(() => {});
|
|
496
|
+
|
|
497
|
+
initSSO();
|
|
498
|
+
|
|
499
|
+
// Handle invite code in URL
|
|
500
|
+
const urlCode = new URLSearchParams(window.location.search).get('code');
|
|
501
|
+
if (urlCode) {
|
|
502
|
+
document.getElementById('reg-email').focus();
|
|
503
|
+
showSection('register');
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
applyI18n();
|
|
507
|
+
</script>
|
|
508
|
+
</body>
|
|
509
|
+
</html>
|