Files
faq_chatbot_frontend/src/app/pages/login/login.page.html
T
PeymanHonarjoo 447849289e feat(auth): implement login page and authentication flow
Implement a complete authentication system including a new login page,
updated authentication service, and conditional routing.

- Add `LoginPage` component with animated UI and form validation
- Update `AuthService` to handle user sessions, CSRF tokens, and
  enhanced user data structures
- Implement conditional rendering in `App` component based on
  authentication state
- Add `postRaw` and `getRaw` methods to `HttpService` for direct
  API interaction
- Update routing to include login path and prepare for auth guards
- Add rate limiting error handling (429) in `HttpService`
2026-10-08 12:49:13 +03:30

226 lines
7.8 KiB
HTML

<div class="login-page" (mousemove)="onCardMouseMove($event)" (mouseleave)="onCardMouseLeave()">
<div class="login-ambient-bg" aria-hidden="true">
<span class="blob blob-1"></span>
<span class="blob blob-2"></span>
<span class="blob blob-3"></span>
<div
class="particles"
aria-hidden="true"
[style.--mouse-x]="mousePosition().x + '%'"
[style.--mouse-y]="mousePosition().y + '%'"
>
<div class="particles-spotlight" aria-hidden="true"></div>
</div>
</div>
<div class="login-card" [class.enter]="isEntering()" [class.shaking]="isShaking()">
<div
class="login-card-inner"
[style.--mouse-x]="mousePosition().x + '%'"
[style.--mouse-y]="mousePosition().y + '%'"
>
<div class="login-spotlight" aria-hidden="true"></div>
<div class="login-glow-border" aria-hidden="true"></div>
<div class="login-header">
<div class="login-logo-wrapper">
<div class="logo-ring" aria-hidden="true"></div>
<img
class="login-logo"
src="assets/images/RaymandLogo.png"
alt="Raymand"
(click)="onLogoClick()"
/>
</div>
<h1 class="login-title">ورود به حساب کاربری</h1>
</div>
<form class="login-form" (ngSubmit)="onSubmit()" novalidate autocomplete="on">
<div class="form-field" [class.has-error]="errors().username">
<label for="login-username" class="form-label"> نام کاربری </label>
<div class="input-wrapper">
<span class="input-icon" aria-hidden="true">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
<circle cx="12" cy="7" r="4" />
</svg>
</span>
<input
id="login-username"
type="text"
class="form-input"
[value]="username()"
(input)="username.set($any($event.target).value)"
(blur)="onFieldBlur('username')"
placeholder="نام کاربری خود را وارد کنید"
autocomplete="username"
[disabled]="isLoading()"
aria-invalid="!!errors().username"
aria-describedby="username-error"
/>
</div>
@if (errors().username) {
<span id="username-error" class="field-error" role="alert">
{{ errors().username }}
</span>
}
</div>
<div class="form-field" [class.has-error]="errors().password">
<label for="login-password" class="form-label"> رمز عبور </label>
<div class="input-wrapper">
<span class="input-icon" aria-hidden="true">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
<path d="M7 11V7a5 5 0 0 1 10 0v4" />
</svg>
</span>
<input
id="login-password"
[type]="showPassword() ? 'text' : 'password'"
class="form-input"
[value]="password()"
(input)="password.set($any($event.target).value)"
(blur)="onFieldBlur('password')"
placeholder="رمز عبور خود را وارد کنید"
autocomplete="current-password"
[disabled]="isLoading()"
aria-invalid="!!errors().password"
aria-describedby="password-error"
/>
<button
type="button"
class="password-toggle"
(click)="togglePasswordVisibility()"
[attr.aria-label]="showPassword() ? 'مخفی کردن رمز عبور' : 'نمایش رمز عبور'"
[disabled]="isLoading()"
>
@if (showPassword()) {
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path
d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"
/>
<path
d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"
/>
<path d="M14.12 14.12a3 3 0 1 1-4.24-4.24" />
<line x1="1" y1="1" x2="23" y2="23" />
</svg>
} @else {
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
<circle cx="12" cy="12" r="3" />
</svg>
}
</button>
</div>
@if (errors().password) {
<span id="password-error" class="field-error" role="alert">
{{ errors().password }}
</span>
}
</div>
<div class="form-options">
<label class="remember-me">
<input
type="checkbox"
class="remember-checkbox"
[checked]="rememberMe()"
(change)="rememberMe.set($any($event.target).checked)"
[disabled]="isLoading()"
/>
<span class="remember-label">مرا به خاطر بسپار</span>
</label>
</div>
@if (generalError()) {
<div class="general-error" role="alert">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<circle cx="12" cy="12" r="10" />
<line x1="12" y1="8" x2="12" y2="12" />
<line x1="12" y1="16" x2="12.01" y2="16" />
</svg>
<span>{{ generalError() }}</span>
</div>
}
<button
type="submit"
class="login-submit"
[class.loading]="isLoading()"
[disabled]="isLoading()"
>
<span class="btn-shimmer" aria-hidden="true"></span>
@if (isLoading()) {
<span class="spinner" aria-hidden="true"></span>
<span class="btn-text">در حال ورود...</span>
} @else {
<span class="btn-text">ورود</span>
<span class="btn-arrow" aria-hidden="true">
<svg
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.5"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M5 12h14M12 5l7 7-7 7" />
</svg>
</span>
}
</button>
</form>
</div>
</div>
</div>