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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fa" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ورود به پلتفرم آموزشی - RewardApp</title>
|
| 7 |
+
<meta name="description" content="ورود به پلتفرم آموزش توسعه وب">
|
| 8 |
+
|
| 9 |
+
<!-- استایلها -->
|
| 10 |
+
<link rel="stylesheet" href="css/style.css">
|
| 11 |
+
<link rel="stylesheet" href="css/auth.css">
|
| 12 |
+
<link rel="stylesheet" href="css/responsive.css">
|
| 13 |
+
|
| 14 |
+
<style>
|
| 15 |
+
.auth-container {
|
| 16 |
+
min-height: 100vh;
|
| 17 |
+
display: flex;
|
| 18 |
+
align-items: center;
|
| 19 |
+
justify-content: center;
|
| 20 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 21 |
+
padding: 20px;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.auth-card {
|
| 25 |
+
background: white;
|
| 26 |
+
border-radius: 20px;
|
| 27 |
+
padding: 40px;
|
| 28 |
+
box-shadow: 0 20px 60px rgba(0,0,0,0.1);
|
| 29 |
+
width: 100%;
|
| 30 |
+
max-width: 400px;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.auth-logo {
|
| 34 |
+
text-align: center;
|
| 35 |
+
margin-bottom: 30px;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.auth-logo h1 {
|
| 39 |
+
color: #4a5568;
|
| 40 |
+
margin-bottom: 10px;
|
| 41 |
+
font-size: 24px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.auth-logo p {
|
| 45 |
+
color: #718096;
|
| 46 |
+
font-size: 14px;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.auth-form .form-group {
|
| 50 |
+
margin-bottom: 20px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.auth-form label {
|
| 54 |
+
display: block;
|
| 55 |
+
margin-bottom: 8px;
|
| 56 |
+
color: #4a5568;
|
| 57 |
+
font-weight: 600;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.auth-form input {
|
| 61 |
+
width: 100%;
|
| 62 |
+
padding: 12px 16px;
|
| 63 |
+
border: 2px solid #e2e8f0;
|
| 64 |
+
border-radius: 10px;
|
| 65 |
+
font-size: 16px;
|
| 66 |
+
transition: all 0.3s ease;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.auth-form input:focus {
|
| 70 |
+
outline: none;
|
| 71 |
+
border-color: #667eea;
|
| 72 |
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.btn-auth {
|
| 76 |
+
width: 100%;
|
| 77 |
+
padding: 12px;
|
| 78 |
+
background: #667eea;
|
| 79 |
+
color: white;
|
| 80 |
+
border: none;
|
| 81 |
+
border-radius: 10px;
|
| 82 |
+
font-size: 16px;
|
| 83 |
+
font-weight: 600;
|
| 84 |
+
cursor: pointer;
|
| 85 |
+
transition: all 0.3s ease;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.btn-auth:hover {
|
| 89 |
+
background: #5a67d8;
|
| 90 |
+
transform: translateY(-2px);
|
| 91 |
+
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.auth-links {
|
| 95 |
+
text-align: center;
|
| 96 |
+
margin-top: 20px;
|
| 97 |
+
padding-top: 20px;
|
| 98 |
+
border-top: 1px solid #e2e8f0;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.auth-links a {
|
| 102 |
+
color: #667eea;
|
| 103 |
+
text-decoration: none;
|
| 104 |
+
margin: 0 10px;
|
| 105 |
+
transition: color 0.3s ease;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.auth-links a:hover {
|
| 109 |
+
color: #5a67d8;
|
| 110 |
+
text-decoration: underline;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.error-message {
|
| 114 |
+
background: #fed7d7;
|
| 115 |
+
color: #742a2a;
|
| 116 |
+
padding: 10px;
|
| 117 |
+
border-radius: 8px;
|
| 118 |
+
margin-bottom: 20px;
|
| 119 |
+
text-align: center;
|
| 120 |
+
display: none;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.success-message {
|
| 124 |
+
background: #c6f6d5;
|
| 125 |
+
color: #22543d;
|
| 126 |
+
padding: 10px;
|
| 127 |
+
border-radius: 8px;
|
| 128 |
+
margin-bottom: 20px;
|
| 129 |
+
text-align: center;
|
| 130 |
+
display: none;
|
| 131 |
+
}
|
| 132 |
+
</style>
|
| 133 |
+
</head>
|
| 134 |
+
<body>
|
| 135 |
+
<div class="auth-container">
|
| 136 |
+
<div class="auth-card">
|
| 137 |
+
<div class="auth-logo">
|
| 138 |
+
<h1>🎓 RewardApp</h1>
|
| 139 |
+
<p>پلتفرم آموزش توسعه وب</p>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<div id="errorMessage" class="error-message"></div>
|
| 143 |
+
<div id="successMessage" class="success-message"></div>
|
| 144 |
+
|
| 145 |
+
<form id="loginForm" class="auth-form">
|
| 146 |
+
<div class="form-group">
|
| 147 |
+
<label for="username">نام کاربری</label>
|
| 148 |
+
<input
|
| 149 |
+
type="text"
|
| 150 |
+
id="username"
|
| 151 |
+
name="username"
|
| 152 |
+
placeholder="نام کاربری خود را وارد کنید"
|
| 153 |
+
required
|
| 154 |
+
>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<div class="form-group">
|
| 158 |
+
<label for="password">رمز عبور</label>
|
| 159 |
+
<input
|
| 160 |
+
type="password"
|
| 161 |
+
id="password"
|
| 162 |
+
name="password"
|
| 163 |
+
placeholder="رمز عبور خود را وارد کنید"
|
| 164 |
+
required
|
| 165 |
+
>
|
| 166 |
+
</div>
|
| 167 |
+
|
| 168 |
+
<button type="submit" class="btn-auth">ورود به سیستم</button>
|
| 169 |
+
</form>
|
| 170 |
+
|
| 171 |
+
<div class="auth-links">
|
| 172 |
+
<a href="register.html">حساب کاربری ندارید؟ ثبت نام</a>
|
| 173 |
+
<br>
|
| 174 |
+
<a href="index.html">بازگشت به صفحه اصلی</a>
|
| 175 |
+
</div>
|
| 176 |
+
|
| 177 |
+
<div class="demo-accounts" style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e2e8f0;">
|
| 178 |
+
<h3 style="text-align: center; color: #718096; font-size: 14px; margin-bottom: 15px;">حسابهای دمو:</h3>
|
| 179 |
+
<div style="display: grid; gap: 10px; font-size: 12px;">
|
| 180 |
+
<div style="display: flex; justify-content: space-between;">
|
| 181 |
+
<span>دانشجو:</span>
|
| 182 |
+
<span><strong>student</strong> / <strong>password123</strong></span>
|
| 183 |
+
</div>
|
| 184 |
+
<div style="display: flex; justify-content: space-between;">
|
| 185 |
+
<span>مدیر:</span>
|
| 186 |
+
<span><strong>admin</strong> / <strong>admin123</strong></span>
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
</div>
|
| 192 |
+
|
| 193 |
+
<!-- اسکریپتهای مورد نیاز -->
|
| 194 |
+
<script src="js/auth/authentication.js"></script>
|
| 195 |
+
<script src="js/auth/authorization.js"></script>
|
| 196 |
+
<script src="js/auth/user_management.js"></script>
|
| 197 |
+
<script src="js/middleware/validation_middleware.js"></script>
|
| 198 |
+
|
| 199 |
+
<script>
|
| 200 |
+
class LoginPage {
|
| 201 |
+
constructor() {
|
| 202 |
+
this.init();
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
init() {
|
| 206 |
+
this.setupEventListeners();
|
| 207 |
+
this.checkExistingAuth();
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
setupEventListeners() {
|
| 211 |
+
const loginForm = document.getElementById('loginForm');
|
| 212 |
+
if (loginForm) {
|
| 213 |
+
loginForm.addEventListener('submit', (e) => {
|
| 214 |
+
e.preventDefault();
|
| 215 |
+
this.handleLogin();
|
| 216 |
+
});
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// مدیریت نمایش/پنهان کردن پیامها
|
| 220 |
+
document.addEventListener('click', () => {
|
| 221 |
+
this.hideMessages();
|
| 222 |
+
});
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
checkExistingAuth() {
|
| 226 |
+
if (authManager.isAuthenticated()) {
|
| 227 |
+
this.showMessage('شما قبلاً وارد شدهاید. در حال انتقال...', 'success');
|
| 228 |
+
setTimeout(() => {
|
| 229 |
+
window.location.href = 'index.html';
|
| 230 |
+
}, 2000);
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
async handleLogin() {
|
| 235 |
+
const formData = new FormData(document.getElementById('loginForm'));
|
| 236 |
+
const data = {
|
| 237 |
+
username: formData.get('username').trim(),
|
| 238 |
+
password: formData.get('password')
|
| 239 |
+
};
|
| 240 |
+
|
| 241 |
+
// اعتبارسنجی
|
| 242 |
+
const validation = ValidationMiddleware.validateLoginData(data);
|
| 243 |
+
if (!validation.isValid) {
|
| 244 |
+
this.showMessage(validation.errors.join(' • '), 'error');
|
| 245 |
+
return;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// انجام ورود
|
| 249 |
+
const result = authManager.loginUser(data.username, data.password);
|
| 250 |
+
|
| 251 |
+
if (result.success) {
|
| 252 |
+
this.showMessage('ورود موفقیتآمیز! در حال انتقال...', 'success');
|
| 253 |
+
|
| 254 |
+
// ذخیره توکن و کاربر
|
| 255 |
+
authManager.setToken(result.token);
|
| 256 |
+
authManager.setCurrentUser(result.user);
|
| 257 |
+
|
| 258 |
+
setTimeout(() => {
|
| 259 |
+
window.location.href = 'index.html';
|
| 260 |
+
}, 1500);
|
| 261 |
+
} else {
|
| 262 |
+
this.showMessage(result.message || 'خطا در ورود به سیستم', 'error');
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
showMessage(message, type = 'error') {
|
| 267 |
+
const errorElement = document.getElementById('errorMessage');
|
| 268 |
+
const successElement = document.getElementById('successMessage');
|
| 269 |
+
|
| 270 |
+
if (type === 'error') {
|
| 271 |
+
errorElement.textContent = message;
|
| 272 |
+
errorElement.style.display = 'block';
|
| 273 |
+
successElement.style.display = 'none';
|
| 274 |
+
} else {
|
| 275 |
+
successElement.textContent = message;
|
| 276 |
+
successElement.style.display = 'block';
|
| 277 |
+
errorElement.style.display = 'none';
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
// پنهان کردن خودکار پیام بعد از 5 ثانیه
|
| 281 |
+
setTimeout(() => {
|
| 282 |
+
this.hideMessages();
|
| 283 |
+
}, 5000);
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
hideMessages() {
|
| 287 |
+
document.getElementById('errorMessage').style.display = 'none';
|
| 288 |
+
document.getElementById('successMessage').style.display = 'none';
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
// راهاندازی صفحه ورود هنگام بارگذاری
|
| 293 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 294 |
+
new LoginPage();
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
// نمایش خطاهای عمومی
|
| 298 |
+
window.addEventListener('error', (event) => {
|
| 299 |
+
console.error('Global error:', event.error);
|
| 300 |
+
});
|
| 301 |
+
</script>
|
| 302 |
+
</body>
|
| 303 |
+
</html>
|