Spaces:
Running
Running
Update login.html
Browse files- login.html +363 -28
login.html
CHANGED
|
@@ -6,7 +6,274 @@
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</style>
|
| 11 |
</head>
|
| 12 |
<body>
|
|
@@ -16,51 +283,75 @@
|
|
| 16 |
</div>
|
| 17 |
|
| 18 |
<div class="container">
|
| 19 |
-
<div class="
|
| 20 |
<div class="card-header">
|
| 21 |
-
<h1
|
| 22 |
<p>مرحباً بك في نظام المصادقة الذكي</p>
|
| 23 |
</div>
|
| 24 |
|
| 25 |
-
<
|
| 26 |
-
<
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
<div class="form-group">
|
| 29 |
<label class="form-label">اسم المستخدم</label>
|
| 30 |
-
<input
|
| 31 |
-
type="text"
|
| 32 |
-
class="form-input"
|
| 33 |
-
name="username"
|
| 34 |
-
placeholder="أدخل اسم المستخدم"
|
| 35 |
-
required
|
| 36 |
-
>
|
| 37 |
</div>
|
| 38 |
-
|
| 39 |
<div class="form-group">
|
| 40 |
<label class="form-label">كلمة المرور</label>
|
| 41 |
-
<input
|
| 42 |
-
type="password"
|
| 43 |
-
class="form-input"
|
| 44 |
-
name="password"
|
| 45 |
-
placeholder="أدخل كلمة المرور"
|
| 46 |
-
required
|
| 47 |
-
>
|
| 48 |
</div>
|
| 49 |
-
|
| 50 |
<button type="submit" class="submit-btn">تسجيل الدخول</button>
|
| 51 |
</form>
|
| 52 |
|
| 53 |
-
<
|
| 54 |
-
<
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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('
|
| 64 |
|
| 65 |
try {
|
| 66 |
form.classList.add('loading');
|
|
@@ -85,12 +376,56 @@
|
|
| 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 {
|
|
|
|
| 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 |
+
.background-animation {
|
| 39 |
+
position: fixed;
|
| 40 |
+
top: 0;
|
| 41 |
+
left: 0;
|
| 42 |
+
width: 100%;
|
| 43 |
+
height: 100%;
|
| 44 |
+
z-index: 0;
|
| 45 |
+
opacity: 0.5;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.circle {
|
| 49 |
+
position: absolute;
|
| 50 |
+
border-radius: 50%;
|
| 51 |
+
animation: float 15s infinite ease-in-out;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.circle-1 {
|
| 55 |
+
width: 400px;
|
| 56 |
+
height: 400px;
|
| 57 |
+
background: var(--primary-gradient);
|
| 58 |
+
top: -200px;
|
| 59 |
+
left: -200px;
|
| 60 |
+
opacity: 0.2;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.circle-2 {
|
| 64 |
+
width: 500px;
|
| 65 |
+
height: 500px;
|
| 66 |
+
background: var(--secondary-gradient);
|
| 67 |
+
bottom: -250px;
|
| 68 |
+
right: -250px;
|
| 69 |
+
opacity: 0.15;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
@keyframes float {
|
| 73 |
+
0%, 100% { transform: translate(0, 0) rotate(0deg); }
|
| 74 |
+
50% { transform: translate(30px, 30px) rotate(15deg); }
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.container {
|
| 78 |
+
width: 100%;
|
| 79 |
+
max-width: 420px;
|
| 80 |
+
padding: 2rem;
|
| 81 |
+
position: relative;
|
| 82 |
+
z-index: 1;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.auth-card {
|
| 86 |
+
background: var(--bg-card);
|
| 87 |
+
backdrop-filter: blur(10px);
|
| 88 |
+
border: 1px solid var(--border-color);
|
| 89 |
+
border-radius: 24px;
|
| 90 |
+
padding: 2.5rem;
|
| 91 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
| 92 |
+
animation: cardAppear 0.6s ease-out;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
@keyframes cardAppear {
|
| 96 |
+
from { opacity: 0; transform: translateY(20px); }
|
| 97 |
+
to { opacity: 1; transform: translateY(0); }
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.card-header {
|
| 101 |
+
text-align: center;
|
| 102 |
+
margin-bottom: 2rem;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.card-header h1 {
|
| 106 |
+
color: var(--text-primary);
|
| 107 |
+
font-size: 2rem;
|
| 108 |
+
margin-bottom: 0.5rem;
|
| 109 |
+
animation: glowText 2s infinite alternate;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.card-header p {
|
| 113 |
+
color: var(--text-secondary);
|
| 114 |
+
font-size: 1rem;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
@keyframes glowText {
|
| 118 |
+
from { text-shadow: 0 0 10px rgba(79, 70, 229, 0); }
|
| 119 |
+
to { text-shadow: 0 0 20px rgba(79, 70, 229, 0.5); }
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.form-group {
|
| 123 |
+
margin-bottom: 1.5rem;
|
| 124 |
+
position: relative;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.form-label {
|
| 128 |
+
display: block;
|
| 129 |
+
color: var(--text-primary);
|
| 130 |
+
margin-bottom: 0.5rem;
|
| 131 |
+
font-size: 0.95rem;
|
| 132 |
+
font-weight: 500;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.form-input {
|
| 136 |
+
width: 100%;
|
| 137 |
+
padding: 1rem;
|
| 138 |
+
background: rgba(255, 255, 255, 0.05);
|
| 139 |
+
border: 1px solid var(--border-color);
|
| 140 |
+
border-radius: 12px;
|
| 141 |
+
color: var(--text-primary);
|
| 142 |
+
font-size: 1rem;
|
| 143 |
+
transition: all 0.3s ease;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
.form-input:focus {
|
| 147 |
+
outline: none;
|
| 148 |
+
border-color: #4f46e5;
|
| 149 |
+
box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.form-input::placeholder {
|
| 153 |
+
color: var(--text-secondary);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.submit-btn {
|
| 157 |
+
width: 100%;
|
| 158 |
+
padding: 1rem;
|
| 159 |
+
background: var(--primary-gradient);
|
| 160 |
+
border: none;
|
| 161 |
+
border-radius: 12px;
|
| 162 |
+
color: var(--text-primary);
|
| 163 |
+
font-size: 1.1rem;
|
| 164 |
+
font-weight: 600;
|
| 165 |
+
cursor: pointer;
|
| 166 |
+
transition: all 0.3s ease;
|
| 167 |
+
position: relative;
|
| 168 |
+
overflow: hidden;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.submit-btn:hover {
|
| 172 |
+
transform: translateY(-2px);
|
| 173 |
+
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.message {
|
| 177 |
+
padding: 1rem;
|
| 178 |
+
border-radius: 12px;
|
| 179 |
+
margin-bottom: 1.5rem;
|
| 180 |
+
text-align: center;
|
| 181 |
+
animation: messageSlide 0.3s ease-out;
|
| 182 |
+
font-weight: 500;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
@keyframes messageSlide {
|
| 186 |
+
from { opacity: 0; transform: translateY(-10px); }
|
| 187 |
+
to { opacity: 1; transform: translateY(0); }
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
.error-message {
|
| 191 |
+
background: rgba(239, 68, 68, 0.1);
|
| 192 |
+
border: 1px solid rgba(239, 68, 68, 0.2);
|
| 193 |
+
color: var(--text-error);
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.success-message {
|
| 197 |
+
background: rgba(16, 185, 129, 0.1);
|
| 198 |
+
border: 1px solid rgba(16, 185, 129, 0.2);
|
| 199 |
+
color: var(--text-success);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.switch-form {
|
| 203 |
+
text-align: center;
|
| 204 |
+
margin-top: 1.5rem;
|
| 205 |
+
color: var(--text-secondary);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.switch-form a {
|
| 209 |
+
color: #4f46e5;
|
| 210 |
+
text-decoration: none;
|
| 211 |
+
font-weight: 500;
|
| 212 |
+
margin-right: 0.5rem;
|
| 213 |
+
transition: all 0.3s ease;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.switch-form a:hover {
|
| 217 |
+
color: #818cf8;
|
| 218 |
+
text-decoration: underline;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.loading .submit-btn {
|
| 222 |
+
pointer-events: none;
|
| 223 |
+
opacity: 0.7;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.loading .submit-btn::after {
|
| 227 |
+
content: '';
|
| 228 |
+
position: absolute;
|
| 229 |
+
left: 50%;
|
| 230 |
+
top: 50%;
|
| 231 |
+
transform: translate(-50%, -50%);
|
| 232 |
+
width: 20px;
|
| 233 |
+
height: 20px;
|
| 234 |
+
border: 2px solid #ffffff;
|
| 235 |
+
border-radius: 50%;
|
| 236 |
+
border-top-color: transparent;
|
| 237 |
+
animation: spin 1s linear infinite;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
@keyframes spin {
|
| 241 |
+
to { transform: translate(-50%, -50%) rotate(360deg); }
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.tabs {
|
| 245 |
+
display: flex;
|
| 246 |
+
justify-content: center;
|
| 247 |
+
margin-bottom: 2rem;
|
| 248 |
+
gap: 1rem;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.tab {
|
| 252 |
+
padding: 0.5rem 1.5rem;
|
| 253 |
+
border: none;
|
| 254 |
+
background: none;
|
| 255 |
+
color: var(--text-secondary);
|
| 256 |
+
cursor: pointer;
|
| 257 |
+
font-size: 1rem;
|
| 258 |
+
font-weight: 500;
|
| 259 |
+
transition: all 0.3s ease;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
.tab.active {
|
| 263 |
+
color: var(--text-primary);
|
| 264 |
+
position: relative;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.tab.active::after {
|
| 268 |
+
content: '';
|
| 269 |
+
position: absolute;
|
| 270 |
+
bottom: -4px;
|
| 271 |
+
left: 0;
|
| 272 |
+
width: 100%;
|
| 273 |
+
height: 2px;
|
| 274 |
+
background: var(--primary-gradient);
|
| 275 |
+
border-radius: 2px;
|
| 276 |
+
}
|
| 277 |
</style>
|
| 278 |
</head>
|
| 279 |
<body>
|
|
|
|
| 283 |
</div>
|
| 284 |
|
| 285 |
<div class="container">
|
| 286 |
+
<div class="auth-card">
|
| 287 |
<div class="card-header">
|
| 288 |
+
<h1>نظام المصادقة</h1>
|
| 289 |
<p>مرحباً بك في نظام المصادقة الذكي</p>
|
| 290 |
</div>
|
| 291 |
|
| 292 |
+
<div class="tabs">
|
| 293 |
+
<button class="tab active" onclick="switchTab('login')">تسجيل الدخول</button>
|
| 294 |
+
<button class="tab" onclick="switchTab('register')">حساب جديد</button>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
+
<form id="loginForm" style="display: block;">
|
| 298 |
+
<div id="loginMessage"></div>
|
| 299 |
<div class="form-group">
|
| 300 |
<label class="form-label">اسم المستخدم</label>
|
| 301 |
+
<input type="text" class="form-input" name="username" placeholder="أدخل اسم المستخدم" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
</div>
|
|
|
|
| 303 |
<div class="form-group">
|
| 304 |
<label class="form-label">كلمة المرور</label>
|
| 305 |
+
<input type="password" class="form-input" name="password" placeholder="أدخل كلمة المرور" required>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
</div>
|
|
|
|
| 307 |
<button type="submit" class="submit-btn">تسجيل الدخول</button>
|
| 308 |
</form>
|
| 309 |
|
| 310 |
+
<form id="registerForm" style="display: none;">
|
| 311 |
+
<div id="registerMessage"></div>
|
| 312 |
+
<div class="form-group">
|
| 313 |
+
<label class="form-label">اسم المستخدم</label>
|
| 314 |
+
<input type="text" class="form-input" name="username" placeholder="أدخل اسم المستخدم" required>
|
| 315 |
+
</div>
|
| 316 |
+
<div class="form-group">
|
| 317 |
+
<label class="form-label">البريد الإلكتروني</label>
|
| 318 |
+
<input type="email" class="form-input" name="email" placeholder="أدخل البريد الإلكتروني" required>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="form-group">
|
| 321 |
+
<label class="form-label">الاسم الكامل</label>
|
| 322 |
+
<input type="text" class="form-input" name="fullName" placeholder="أدخل اسمك الكامل">
|
| 323 |
+
</div>
|
| 324 |
+
<div class="form-group">
|
| 325 |
+
<label class="form-label">كلمة المرور</label>
|
| 326 |
+
<input type="password" class="form-input" name="password" placeholder="أدخل كلمة المرور" required>
|
| 327 |
+
</div>
|
| 328 |
+
<button type="submit" class="submit-btn">إنشاء حساب</button>
|
| 329 |
+
</form>
|
| 330 |
</div>
|
| 331 |
</div>
|
| 332 |
|
| 333 |
<script>
|
| 334 |
+
function switchTab(tab) {
|
| 335 |
+
const loginForm = document.getElementById('loginForm');
|
| 336 |
+
const registerForm = document.getElementById('registerForm');
|
| 337 |
+
const tabs = document.querySelectorAll('.tab');
|
| 338 |
+
|
| 339 |
+
tabs.forEach(t => t.classList.remove('active'));
|
| 340 |
+
if (tab === 'login') {
|
| 341 |
+
loginForm.style.display = 'block';
|
| 342 |
+
registerForm.style.display = 'none';
|
| 343 |
+
tabs[0].classList.add('active');
|
| 344 |
+
} else {
|
| 345 |
+
loginForm.style.display = 'none';
|
| 346 |
+
registerForm.style.display = 'block';
|
| 347 |
+
tabs[1].classList.add('active');
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
| 352 |
e.preventDefault();
|
| 353 |
const form = e.target;
|
| 354 |
+
const messageBox = document.getElementById('loginMessage');
|
| 355 |
|
| 356 |
try {
|
| 357 |
form.classList.add('loading');
|
|
|
|
| 376 |
localStorage.setItem('token', data.access_token);
|
| 377 |
// Redirect or update UI as needed
|
| 378 |
} else {
|
| 379 |
+
throw new Error(data.detail || 'خطأ في تسجيل الدخول');
|
| 380 |
+
}
|
| 381 |
+
} catch (error) {
|
| 382 |
+
messageBox.innerHTML = `
|
| 383 |
+
<div class="message error-message">
|
| 384 |
+
${error.message === 'Failed to fetch' ? 'فشل الاتصال بالخادم' : error.message}
|
| 385 |
+
</div>
|
| 386 |
+
`;
|
| 387 |
+
} finally {
|
| 388 |
+
form.classList.remove('loading');
|
| 389 |
+
}
|
| 390 |
+
});
|
| 391 |
+
|
| 392 |
+
document.getElementById('registerForm').addEventListener('submit', async (e) => {
|
| 393 |
+
e.preventDefault();
|
| 394 |
+
const form = e.target;
|
| 395 |
+
const messageBox = document.getElementById('registerMessage');
|
| 396 |
+
|
| 397 |
+
try {
|
| 398 |
+
form.classList.add('loading');
|
| 399 |
+
|
| 400 |
+
const response = await fetch('http://localhost:6000/register', {
|
| 401 |
+
method: 'POST',
|
| 402 |
+
headers: {
|
| 403 |
+
'Content-Type': 'application/json',
|
| 404 |
+
},
|
| 405 |
+
body: JSON.stringify({
|
| 406 |
+
username: form.username.value,
|
| 407 |
+
email: form.email.value,
|
| 408 |
+
full_name: form.fullName.value,
|
| 409 |
+
password: form.password.value
|
| 410 |
+
})
|
| 411 |
+
});
|
| 412 |
+
|
| 413 |
+
const data = await response.json();
|
| 414 |
+
|
| 415 |
+
if (response.ok) {
|
| 416 |
+
messageBox.innerHTML = `
|
| 417 |
+
<div class="message success-message">
|
| 418 |
+
تم إنشاء الحساب بنجاح
|
| 419 |
+
</div>
|
| 420 |
+
`;
|
| 421 |
+
setTimeout(() => switchTab('login'), 2000);
|
| 422 |
+
} else {
|
| 423 |
+
throw new Error(data.detail || 'خطأ في إنشاء الحساب');
|
| 424 |
}
|
| 425 |
} catch (error) {
|
| 426 |
messageBox.innerHTML = `
|
| 427 |
<div class="message error-message">
|
| 428 |
+
${error.message === 'Failed to fetch' ? 'فشل الاتصال بالخادم' : error.message}
|
| 429 |
</div>
|
| 430 |
`;
|
| 431 |
} finally {
|