joermd commited on
Commit
dd90c38
·
verified ·
1 Parent(s): e400142

Update login.html

Browse files
Files changed (1) hide show
  1. login.html +21 -309
login.html CHANGED
@@ -6,298 +6,15 @@
6
  <title>نظام المصادقة الذكي</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap" rel="stylesheet">
8
  <style>
9
- :root {
10
- --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
11
- --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
12
- --text-primary: #ffffff;
13
- --text-secondary: #94a3b8;
14
- --text-error: #ef4444;
15
- --text-success: #10b981;
16
- --bg-dark: #0f172a;
17
- --bg-card: rgba(255, 255, 255, 0.05);
18
- --border-color: rgba(255, 255, 255, 0.1);
19
- }
20
-
21
- * {
22
- margin: 0;
23
- padding: 0;
24
- box-sizing: border-box;
25
- font-family: 'Cairo', sans-serif;
26
- }
27
-
28
- body {
29
- min-height: 100vh;
30
- display: flex;
31
- justify-content: center;
32
- align-items: center;
33
- background: var(--bg-dark);
34
- position: relative;
35
- overflow: hidden;
36
- }
37
-
38
- /* Animation Background */
39
- .background-animation {
40
- position: fixed;
41
- top: 0;
42
- left: 0;
43
- width: 100%;
44
- height: 100%;
45
- z-index: 0;
46
- opacity: 0.5;
47
- }
48
-
49
- .circle {
50
- position: absolute;
51
- border-radius: 50%;
52
- animation: float 15s infinite ease-in-out;
53
- }
54
-
55
- .circle-1 {
56
- width: 400px;
57
- height: 400px;
58
- background: var(--primary-gradient);
59
- top: -200px;
60
- left: -200px;
61
- opacity: 0.2;
62
- }
63
-
64
- .circle-2 {
65
- width: 500px;
66
- height: 500px;
67
- background: var(--secondary-gradient);
68
- bottom: -250px;
69
- right: -250px;
70
- opacity: 0.15;
71
- }
72
-
73
- @keyframes float {
74
- 0%, 100% {
75
- transform: translate(0, 0) rotate(0deg);
76
- }
77
- 50% {
78
- transform: translate(30px, 30px) rotate(15deg);
79
- }
80
- }
81
-
82
- /* Container and Card */
83
- .container {
84
- width: 100%;
85
- max-width: 420px;
86
- padding: 2rem;
87
- position: relative;
88
- z-index: 1;
89
- }
90
-
91
- .login-card {
92
- background: var(--bg-card);
93
- backdrop-filter: blur(10px);
94
- border: 1px solid var(--border-color);
95
- border-radius: 24px;
96
- padding: 2.5rem;
97
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
98
- animation: cardAppear 0.6s ease-out;
99
- }
100
-
101
- @keyframes cardAppear {
102
- from {
103
- opacity: 0;
104
- transform: translateY(20px);
105
- }
106
- to {
107
- opacity: 1;
108
- transform: translateY(0);
109
- }
110
- }
111
-
112
- /* Header */
113
- .card-header {
114
- text-align: center;
115
- margin-bottom: 2rem;
116
- }
117
-
118
- .card-header h1 {
119
- color: var(--text-primary);
120
- font-size: 2rem;
121
- margin-bottom: 0.5rem;
122
- animation: glowText 2s infinite alternate;
123
- }
124
-
125
- .card-header p {
126
- color: var(--text-secondary);
127
- font-size: 1rem;
128
- }
129
-
130
- @keyframes glowText {
131
- from { text-shadow: 0 0 10px rgba(79, 70, 229, 0); }
132
- to { text-shadow: 0 0 20px rgba(79, 70, 229, 0.5); }
133
- }
134
-
135
- /* Form Elements */
136
- .form-group {
137
- margin-bottom: 1.5rem;
138
- position: relative;
139
- }
140
-
141
- .form-label {
142
- display: block;
143
- color: var(--text-primary);
144
- margin-bottom: 0.5rem;
145
- font-size: 0.95rem;
146
- font-weight: 500;
147
- }
148
-
149
- .form-input {
150
- width: 100%;
151
- padding: 1rem;
152
- background: rgba(255, 255, 255, 0.05);
153
- border: 1px solid var(--border-color);
154
- border-radius: 12px;
155
- color: var(--text-primary);
156
- font-size: 1rem;
157
- transition: all 0.3s ease;
158
- }
159
-
160
- .form-input:focus {
161
- outline: none;
162
- border-color: #4f46e5;
163
- box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
164
- }
165
-
166
- .form-input::placeholder {
167
- color: var(--text-secondary);
168
- }
169
-
170
- /* Button */
171
- .submit-btn {
172
- width: 100%;
173
- padding: 1rem;
174
- background: var(--primary-gradient);
175
- border: none;
176
- border-radius: 12px;
177
- color: var(--text-primary);
178
- font-size: 1.1rem;
179
- font-weight: 600;
180
- cursor: pointer;
181
- transition: all 0.3s ease;
182
- position: relative;
183
- overflow: hidden;
184
- }
185
-
186
- .submit-btn::after {
187
- content: '';
188
- position: absolute;
189
- top: -50%;
190
- left: -50%;
191
- width: 200%;
192
- height: 200%;
193
- background: linear-gradient(
194
- transparent,
195
- rgba(255, 255, 255, 0.2),
196
- transparent
197
- );
198
- transform: rotate(45deg);
199
- transition: 0.5s;
200
- }
201
-
202
- .submit-btn:hover::after {
203
- left: 100%;
204
- }
205
-
206
- .submit-btn:hover {
207
- transform: translateY(-2px);
208
- box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
209
- }
210
-
211
- /* Messages */
212
- .message {
213
- padding: 1rem;
214
- border-radius: 12px;
215
- margin-bottom: 1.5rem;
216
- text-align: center;
217
- animation: messageSlide 0.3s ease-out;
218
- }
219
-
220
- @keyframes messageSlide {
221
- from {
222
- opacity: 0;
223
- transform: translateY(-10px);
224
- }
225
- to {
226
- opacity: 1;
227
- transform: translateY(0);
228
- }
229
- }
230
-
231
- .success-message {
232
- background: rgba(16, 185, 129, 0.1);
233
- border: 1px solid rgba(16, 185, 129, 0.2);
234
- color: var(--text-success);
235
- }
236
-
237
- .error-message {
238
- background: rgba(239, 68, 68, 0.1);
239
- border: 1px solid rgba(239, 68, 68, 0.2);
240
- color: var(--text-error);
241
- }
242
-
243
- /* Links */
244
- .switch-form {
245
- text-align: center;
246
- margin-top: 1.5rem;
247
- }
248
-
249
- .switch-form p {
250
- color: var(--text-secondary);
251
- }
252
-
253
- .switch-form a {
254
- color: #4f46e5;
255
- text-decoration: none;
256
- font-weight: 500;
257
- margin-right: 0.5rem;
258
- transition: all 0.3s ease;
259
- }
260
-
261
- .switch-form a:hover {
262
- color: #818cf8;
263
- text-decoration: underline;
264
- }
265
-
266
- /* Loading State */
267
- .loading .submit-btn {
268
- pointer-events: none;
269
- opacity: 0.7;
270
- }
271
-
272
- .loading .submit-btn::before {
273
- content: '';
274
- position: absolute;
275
- left: 50%;
276
- top: 50%;
277
- transform: translate(-50%, -50%);
278
- width: 20px;
279
- height: 20px;
280
- border: 2px solid #ffffff;
281
- border-radius: 50%;
282
- border-top-color: transparent;
283
- animation: spin 1s linear infinite;
284
- }
285
-
286
- @keyframes spin {
287
- to {
288
- transform: translate(-50%, -50%) rotate(360deg);
289
- }
290
- }
291
  </style>
292
  </head>
293
  <body>
294
- <!-- Background Animation -->
295
  <div class="background-animation">
296
  <div class="circle circle-1"></div>
297
  <div class="circle circle-2"></div>
298
  </div>
299
 
300
- <!-- Main Container -->
301
  <div class="container">
302
  <div class="login-card">
303
  <div class="card-header">
@@ -334,53 +51,48 @@
334
  </form>
335
 
336
  <div class="switch-form">
337
- <p>ليس لديك حساب؟ <a href="register.html">إنشاء حساب جديد</a></p>
338
  </div>
339
  </div>
340
  </div>
341
 
342
  <script>
343
- const API_URL = 'http://localhost:6000';
344
- const loginForm = document.getElementById('loginForm');
345
- const messageBox = document.getElementById('messageBox');
346
-
347
- function showMessage(type, text) {
348
- messageBox.innerHTML = `<div class="message ${type}-message">${text}</div>`;
349
- }
350
-
351
- loginForm.addEventListener('submit', async (e) => {
352
  e.preventDefault();
353
  const form = e.target;
354
- form.classList.add('loading');
355
 
356
  try {
357
- const formData = new URLSearchParams();
 
 
358
  formData.append('username', form.username.value);
359
  formData.append('password', form.password.value);
360
 
361
- const response = await fetch(`${API_URL}/token`, {
362
  method: 'POST',
363
- headers: {
364
- 'Content-Type': 'application/x-www-form-urlencoded'
365
- },
366
  body: formData
367
  });
368
-
369
  const data = await response.json();
370
 
371
  if (response.ok) {
372
- showMessage('success', 'تم تسجيل الدخول بنجاح! جاري التحويل...');
 
 
 
 
373
  localStorage.setItem('token', data.access_token);
374
-
375
- setTimeout(() => {
376
- window.location.href = 'https://joermd-mostasharak.static.hf.space';
377
- }, 1500);
378
  } else {
379
- showMessage('error', data.detail || 'فشل تسجيل الدخول');
380
  }
381
  } catch (error) {
382
- showMessage('error', 'حدث خطأ في الاتصال بالخادم');
383
- console.error('Error:', error);
 
 
 
384
  } finally {
385
  form.classList.remove('loading');
386
  }
 
6
  <title>نظام المصادقة الذكي</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap" rel="stylesheet">
8
  <style>
9
+ /* Your existing CSS remains the same */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </style>
11
  </head>
12
  <body>
 
13
  <div class="background-animation">
14
  <div class="circle circle-1"></div>
15
  <div class="circle circle-2"></div>
16
  </div>
17
 
 
18
  <div class="container">
19
  <div class="login-card">
20
  <div class="card-header">
 
51
  </form>
52
 
53
  <div class="switch-form">
54
+ <p>ليس لديك حساب؟ <a href="#" id="switchToRegister">إنشاء حساب جديد</a></p>
55
  </div>
56
  </div>
57
  </div>
58
 
59
  <script>
60
+ document.getElementById('loginForm').addEventListener('submit', async (e) => {
 
 
 
 
 
 
 
 
61
  e.preventDefault();
62
  const form = e.target;
63
+ const messageBox = document.getElementById('messageBox');
64
 
65
  try {
66
+ form.classList.add('loading');
67
+
68
+ const formData = new FormData();
69
  formData.append('username', form.username.value);
70
  formData.append('password', form.password.value);
71
 
72
+ const response = await fetch('http://localhost:6000/token', {
73
  method: 'POST',
 
 
 
74
  body: formData
75
  });
76
+
77
  const data = await response.json();
78
 
79
  if (response.ok) {
80
+ messageBox.innerHTML = `
81
+ <div class="message success-message">
82
+ تم تسجيل الدخول بنجاح
83
+ </div>
84
+ `;
85
  localStorage.setItem('token', data.access_token);
86
+ // Redirect or update UI as needed
 
 
 
87
  } else {
88
+ throw new Error(data.detail || 'حدث خطأ أثناء تسجيل الدخول');
89
  }
90
  } catch (error) {
91
+ messageBox.innerHTML = `
92
+ <div class="message error-message">
93
+ ${error.message}
94
+ </div>
95
+ `;
96
  } finally {
97
  form.classList.remove('loading');
98
  }