From 447849289eb82bb1cd795cacfc9eb2f3a9e625ac Mon Sep 17 00:00:00 2001 From: PeymanHonarjoo Date: Thu, 8 Oct 2026 12:49:13 +0330 Subject: [PATCH] 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` --- public/favicon.ico | Bin 15086 -> 14990 bytes src/app/app.html | 6 +- src/app/app.routes.ts | 24 + src/app/app.ts | 24 +- src/app/pages/login/login.page.css | 894 ++++++++++++++++++ src/app/pages/login/login.page.html | 225 +++++ src/app/pages/login/login.page.ts | 196 ++++ src/app/services/auth/auth.service.ts | 115 ++- src/app/services/http-request/http.service.ts | 25 + 9 files changed, 1470 insertions(+), 39 deletions(-) create mode 100644 src/app/pages/login/login.page.css create mode 100644 src/app/pages/login/login.page.html create mode 100644 src/app/pages/login/login.page.ts diff --git a/public/favicon.ico b/public/favicon.ico index 57614f9c967596fad0a3989bec2b1deff33034f6..a5128e8d6e6e6d13c70b506446a08e3dd02f1617 100644 GIT binary patch literal 14990 zcmb_@byQSe*YFS`D5->iG}4_ibPPCjcSsCK4c##qgdiYY5(3hKbTcR*($XD*v~>4( z2Y=7|ylZ{W_x|&}t~HB$&)s{Ub9V2uk8jmg74Ys++yj9?c+h8ZnjjE5@Q5~zjRpK^ zwxy2%{*b#v^xd_btlhoLU11<;D<=yWE!5H62Brx!xAJl6f{B4Z7;kK~_1*PVl);ux zj$Gy_7%p!|X8;=n5|i|HHn+5gxzk#}Y;57;^gE46dRkj6ae6&L6&@95S=bBPXTGj5 zEnih_OJ93S5i5F030g64FhIZ&=59{w?dSk^1AB|p-_ivG&!}N;dfHnMcYAUAzl+jW zQKyx4a)r?fatU%;^6>G}3X5>@3JMAf^KsDf@$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WG$?J)MdmEk{U!!$M#fp7*Wo}jJ$Q(=8>R`Ats?e|VU?Zt7Cdh%AdnfyN3MBWw{ z$OnREvPf7%z6`#2##_7id|H%Y{vV^vWXb?5d5?a_y&t3@p9t$ncHj-NBdo&X{wrfJ zamN)VMYROYh_SvjJ=Xd!Ga?PY_$;*L=SxFte!4O6%0HEh%iZ4=gvns7IWIyJHa|hT z2;1+e)`TvbNb3-0z&DD_)Jomsg-7p_Uh`wjGnU1urmv1_oVqRg#=C?e?!7DgtqojU zWoAB($&53;TsXu^@2;8M`#z{=rPy?JqgYM0CDf4v@z=ZD|ItJ&8%_7A#K?S{wjxgd z?xA6JdJojrWpB7fr2p_MSsU4(R7=XGS0+Eg#xR=j>`H@R9{XjwBmqAiOxOL` zt?XK-iTEOWV}f>Pz3H-s*>W z4~8C&Xq25UQ^xH6H9kY_RM1$ch+%YLF72AA7^b{~VNTG}Tj#qZltz5Q=qxR`&oIlW Nr__JTFzvMr^FKp4S3v*( diff --git a/src/app/app.html b/src/app/app.html index 2db4341..a5c83b5 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -1 +1,5 @@ - +@if (isAuthenticated()) { + +} @else { + +} diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 4cfa961..ae19abb 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,16 +1,40 @@ import { Routes } from '@angular/router'; import { HomePage } from './pages/home/home.page'; import { SettingsPage } from './pages/settings/settings.page'; +import { LoginPage } from './pages/login/login.page'; +import { AuthService } from './services/auth/auth.service'; +import { authGuard } from './services/auth/auth.guard'; +import { Router } from '@angular/router'; +import { inject } from '@angular/core'; + +const redirectAuthenticated = () => { + const authService = inject(AuthService); + const router = inject(Router); + + if (authService.isAuthenticated()) { + router.navigate(['/']); + return false; + } + return true; +}; export const routes: Routes = [ + { + path: 'login', + title: 'ورود', + component: LoginPage, + // canActivate: [redirectAuthenticated], + }, { path: '', title: 'دستیار هوشمند', component: HomePage, + // canActivate: [authGuard], }, { path: 'settings', title: 'تنظیمات', component: SettingsPage, + // canActivate: [authGuard], }, ]; diff --git a/src/app/app.ts b/src/app/app.ts index e1512fb..f7c86c1 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,10 +1,26 @@ -import { Component } from '@angular/core'; +import { Component, inject, signal } from '@angular/core'; +import { CommonModule } from '@angular/common'; import { LayoutComponent } from './layout/layout.component'; +import { LoginPage } from './pages/login/login.page'; +import { AuthService } from './services/auth/auth.service'; @Component({ selector: 'app-root', - imports: [LayoutComponent], + standalone: true, + imports: [CommonModule, LayoutComponent, LoginPage], templateUrl: './app.html', - styleUrl: './app.css' + styleUrl: './app.css', }) -export class App {} +export class App { + private readonly authService = inject(AuthService); + + readonly isAuthenticated = signal(this.authService.isAuthenticated()); + + constructor() { + this.authService.currentUserSubject.subscribe({ + next: () => { + this.isAuthenticated.set(this.authService.isAuthenticated()); + }, + }); + } +} diff --git a/src/app/pages/login/login.page.css b/src/app/pages/login/login.page.css new file mode 100644 index 0000000..9588c00 --- /dev/null +++ b/src/app/pages/login/login.page.css @@ -0,0 +1,894 @@ +.login-page { + position: relative; + display: flex; + align-items: center; + justify-content: center; + min-height: 100dvh; + padding: 1.5rem 1rem; + box-sizing: border-box; + overflow: hidden; + background: #0f172a; + transition: background 0.6s ease; +} + +.login-page.shaking { + overflow: hidden; +} + +.login-card { + position: relative; + z-index: 1; + width: 100%; + max-width: 440px; + perspective: 1200px; + will-change: transform; + transform: translate3d(0, 0, 0); + transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); +} + +.login-card.enter { + animation: cardEntrance 1s cubic-bezier(0.22, 1, 0.36, 1) both; +} + +.login-card.shaking { + animation: shake 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards; +} + +.login-ambient-bg { + position: absolute; + inset: 0; + overflow: hidden; + pointer-events: none; + z-index: 0; +} + +.particles { + position: absolute; + inset: 0; + background-image: + radial-gradient(circle, rgba(148, 163, 184, 0.08) 1px, transparent 1px), + radial-gradient(circle, rgba(148, 163, 184, 0.06) 1px, transparent 1px); + background-size: 50px 50px, 80px 80px; + background-position: 0 0, 25px 25px; +} + +.particles-spotlight { + position: absolute; + inset: 0; + background-image: + radial-gradient(circle, rgba(148, 163, 184, 0.35) 1px, transparent 1px), + radial-gradient(circle, rgba(148, 163, 184, 0.25) 1px, transparent 1px); + background-size: 50px 50px, 80px 80px; + background-position: 0 0, 25px 25px; + mask-image: radial-gradient( + circle 200px at var(--mouse-x) var(--mouse-y), + black 0%, + black 25%, + transparent 65% + ); + -webkit-mask-image: radial-gradient( + circle 200px at var(--mouse-x) var(--mouse-y), + black 0%, + black 25%, + transparent 65% + ); + transition: mask-image 0.12s ease-out; +} + +@keyframes particlesFloat { + 0% { + transform: translateY(0); + } + 100% { + transform: translateY(-50px); + } +} + +.blob { + position: absolute; + border-radius: 50%; + filter: blur(90px); + opacity: 0.55; + animation: floatBlob 14s ease-in-out infinite; + will-change: transform; +} + +.blob-1 { + width: 520px; + height: 520px; + background: radial-gradient(circle, rgba(59, 130, 246, 0.5), transparent 70%); + top: -18%; + right: -12%; + animation-delay: 0s; + animation-duration: 16s; +} + +.blob-2 { + width: 420px; + height: 420px; + background: radial-gradient(circle, rgba(139, 92, 246, 0.4), transparent 70%); + bottom: -14%; + left: -10%; + animation-delay: -6s; + animation-duration: 18s; +} + +.blob-3 { + width: 360px; + height: 360px; + background: radial-gradient(circle, rgba(59, 130, 246, 0.35), transparent 70%); + top: 45%; + left: 45%; + animation-delay: -11s; + animation-duration: 20s; +} + +@keyframes floatBlob { + 0%, + 100% { + transform: translate(0, 0) scale(1); + } + 25% { + transform: translate(50px, -40px) scale(1.1); + } + 50% { + transform: translate(-30px, 35px) scale(0.92); + } + 75% { + transform: translate(-45px, -20px) scale(1.06); + } +} + +.login-card-inner { + position: relative; + background: rgba(15, 23, 42, 0.65); + border: 1px solid rgba(148, 163, 184, 0.15); + border-radius: 1.5rem; + padding: 2.5rem 2rem 2rem; + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.05) inset, + 0 20px 50px -12px rgba(0, 0, 0, 0.5), + 0 0 80px -20px rgba(59, 130, 246, 0.3); + transition: + background 0.6s ease, + border-color 0.6s ease, + box-shadow 0.6s ease, + transform 0.4s cubic-bezier(0.22, 1, 0.36, 1); + animation: innerReveal 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both; + transform-style: preserve-3d; +} + +.login-card-inner:hover { + transform: translateY(-4px) rotateX(2deg); + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.08) inset, + 0 30px 70px -15px rgba(0, 0, 0, 0.6), + 0 0 100px -20px rgba(59, 130, 246, 0.4); +} + +.login-spotlight { + position: absolute; + inset: 0; + border-radius: inherit; + background: radial-gradient( + 700px circle at var(--mouse-x) var(--mouse-y), + rgba(59, 130, 246, 0.2), + transparent 40% + ); + pointer-events: none; + z-index: 0; + opacity: 0; + transition: opacity 0.5s ease; + mix-blend-mode: screen; +} + +.login-card-inner:hover .login-spotlight { + opacity: 1; +} + +.login-glow-border { + position: absolute; + inset: -1px; + border-radius: inherit; + background: radial-gradient( + 500px circle at var(--mouse-x) var(--mouse-y), + rgba(59, 130, 246, 0.7), + transparent 50% + ); + pointer-events: none; + z-index: -1; + opacity: 0; + transition: opacity 0.5s ease; + mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); + mask-composite: exclude; + padding: 1px; +} + +.login-card-inner:hover .login-glow-border { + opacity: 1; +} + +.login-header { + position: relative; + z-index: 1; + text-align: center; + margin-bottom: 2rem; + animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both; +} + +.login-logo-wrapper { + position: relative; + display: inline-flex; + align-items: center; + justify-content: center; + width: 96px; + height: 96px; + border-radius: 50%; + background: rgba(59, 130, 246, 0.1); + margin-bottom: 1.25rem; + padding: 0.625rem; + cursor: pointer; + transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1); + animation: logoEntrance 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.25s both; +} + +.login-logo-wrapper:hover { + transform: scale(1.12) rotate(10deg); + background: rgba(59, 130, 246, 0.2); + box-shadow: 0 0 50px rgba(59, 130, 246, 0.4); +} + +.logo-ring { + position: absolute; + inset: -6px; + border-radius: 50%; + border: 2px solid transparent; + background: linear-gradient(135deg, rgba(59, 130, 246, 0.7), rgba(139, 92, 246, 0.4), rgba(59, 130, 246, 0.7)) border-box; + mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0); + mask-composite: exclude; + -webkit-mask-composite: xor; + animation: logoRingPulse 3s ease-in-out infinite; +} + +@keyframes logoRingPulse { + 0%, + 100% { + opacity: 0.5; + transform: scale(1) rotate(0deg); + } + 50% { + opacity: 1; + transform: scale(1.15) rotate(180deg); + } +} + +.login-logo { + position: relative; + z-index: 1; + width: 100%; + height: 100%; + object-fit: contain; + display: block; + transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); + filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4)); +} + +.login-logo-wrapper:hover .login-logo { + transform: scale(1.1) rotate(-8deg); +} + +.login-title { + margin: 0 0 0.5rem; + font-size: 1.75rem; + font-weight: 700; + color: #f1f5f9; + line-height: 1.3; + letter-spacing: -0.02em; + text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); + animation: titleGlow 4s ease-in-out infinite; +} + +@keyframes titleGlow { + 0%, + 100% { + text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 transparent; + } + 50% { + text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 40px rgba(59, 130, 246, 0.5), 0 0 80px rgba(139, 92, 246, 0.3); + } +} + +.login-subtitle { + margin: 0; + font-size: 0.9375rem; + color: #94a3b8; + line-height: 1.5; + animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both; +} + +.login-form { + position: relative; + z-index: 1; + display: flex; + flex-direction: column; + gap: 1.25rem; + animation: formReveal 1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s both; +} + +@keyframes formReveal { + from { + opacity: 0; + transform: translateY(32px) scale(0.94); + } + to { + opacity: 1; + transform: translateY(0) scale(1); + } +} + +.form-field { + position: relative; + display: flex; + flex-direction: column; + gap: 0.5rem; + animation: fieldSlideIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; +} + +.form-field:nth-child(1) { + animation-delay: 0.5s; +} + +.form-field:nth-child(2) { + animation-delay: 0.65s; +} + +@keyframes fieldSlideIn { + from { + opacity: 0; + transform: translateX(-20px); + } + to { + opacity: 1; + transform: translateX(0); + } +} + +.form-label { + display: block; + font-size: 0.875rem; + font-weight: 500; + color: #e2e8f0; + line-height: 1.4; + transition: color 0.3s ease; +} + +.form-field:focus-within .form-label { + color: #60a5fa; +} + +.input-wrapper { + position: relative; + display: flex; + align-items: center; +} + +.input-icon { + position: absolute; + right: 0.875rem; + top: 50%; + transform: translateY(-50%); + color: #64748b; + pointer-events: none; + display: flex; + align-items: center; + transition: all 0.3s ease; +} + +.form-field:focus-within .input-icon { + color: #60a5fa; + transform: translateY(-50%) scale(1.2); +} + +.login-page .form-input { + width: 100%; + padding: 0.875rem 2.75rem 0.875rem 0.875rem; + border: 1.5px solid rgba(148, 163, 184, 0.2); + border-radius: 0.75rem; + background-color: rgba(15, 23, 42, 0.6) !important; + background: rgba(15, 23, 42, 0.6) !important; + color: #f1f5f9 !important; + font-family: inherit; + font-size: 0.9375rem; + line-height: 1.5; + transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1); + box-sizing: border-box; + appearance: none !important; + -webkit-appearance: none !important; + -moz-appearance: none !important; +} + +.login-page .form-input:-webkit-autofill, +.login-page .form-input:-webkit-autofill:hover, +.login-page .form-input:-webkit-autofill:focus, +.login-page .form-input:-webkit-autofill:active { + -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.85) inset !important; + box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.85) inset !important; + -webkit-text-fill-color: #f1f5f9 !important; + caret-color: #f1f5f9 !important; + border-color: rgba(148, 163, 184, 0.2) !important; + transition: background-color 5000s ease-in-out 0s; +} + +.login-page .form-input:autofill { + background-color: rgba(15, 23, 42, 0.85) !important; + color: #f1f5f9 !important; + -webkit-text-fill-color: #f1f5f9 !important; +} + +.login-page .form-input:disabled:-webkit-autofill { + -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.4) inset !important; + box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.4) inset !important; +} + +.login-page .form-input::placeholder { + color: #64748b; + opacity: 0.8; +} + +.login-page .form-input:focus { + outline: none; + border-color: #3b82f6; + background-color: rgba(15, 23, 42, 0.8) !important; + background: rgba(15, 23, 42, 0.8) !important; + box-shadow: + 0 0 0 4px rgba(59, 130, 246, 0.15), + 0 0 40px rgba(59, 130, 246, 0.25), + 0 0 0 1px rgba(59, 130, 246, 0.4) inset; + transform: translateY(-2px); +} + +.login-page .form-input:disabled { + opacity: 0.5; + cursor: not-allowed; + background-color: rgba(15, 23, 42, 0.4) !important; + background: rgba(15, 23, 42, 0.4) !important; +} + +.login-page .form-field.has-error .form-input { + border-color: #ef4444; + box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); + animation: errorPulse 2s ease-in-out infinite; +} + +@keyframes errorPulse { + 0%, + 100% { + box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); + } + 50% { + box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.08); + } +} + +.form-field.has-error .input-icon { + color: #ef4444; +} + +.field-error { + display: flex; + align-items: center; + gap: 0.375rem; + font-size: 0.8125rem; + color: #f87171; + line-height: 1.4; + animation: errorShake 0.5s ease both; +} + +@keyframes errorShake { + 0%, + 100% { + transform: translateX(0); + } + 20% { + transform: translateX(-5px); + } + 40% { + transform: translateX(5px); + } + 60% { + transform: translateX(-4px); + } + 80% { + transform: translateX(4px); + } +} + +.password-toggle { + position: absolute; + left: 0.625rem; + top: 50%; + transform: translateY(-50%); + display: inline-flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + border: none; + background: transparent; + color: #64748b; + border-radius: 0.5rem; + cursor: pointer; + transition: all 0.2s ease; + padding: 0; +} + +.password-toggle:hover { + color: #e2e8f0; + background: rgba(59, 130, 246, 0.15); + transform: translateY(-50%) scale(1.2); +} + +.password-toggle:active { + transform: translateY(-50%) scale(0.9); +} + +.password-toggle:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +.form-options { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; + animation: fadeInUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.8s both; +} + +.remember-me { + display: flex; + align-items: center; + gap: 0.5rem; + cursor: pointer; + user-select: none; + position: relative; +} + +.remember-checkbox { + width: 1.125rem; + height: 1.125rem; + accent-color: #3b82f6; + cursor: pointer; + flex-shrink: 0; + transition: transform 0.2s ease; + filter: invert(1) brightness(0.9); +} + +.remember-checkbox:checked { + filter: invert(0) brightness(1); +} + +.remember-me:hover .remember-checkbox { + transform: scale(1.25); +} + +.remember-label { + font-size: 0.875rem; + color: #cbd5e1; + line-height: 1.4; +} + +.general-error { + display: flex; + align-items: center; + gap: 0.625rem; + padding: 0.875rem 1rem; + background: rgba(239, 68, 68, 0.1); + border: 1px solid rgba(239, 68, 68, 0.25); + border-radius: 0.75rem; + color: #fca5a5; + font-size: 0.875rem; + line-height: 1.4; + animation: errorReveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; + box-shadow: 0 0 25px rgba(239, 68, 68, 0.2); +} + +@keyframes errorReveal { + from { + opacity: 0; + transform: translateY(-10px) scale(0.95); + } + to { + opacity: 1; + transform: translateY(0) scale(1); + } +} + +.login-submit { + position: relative; + display: flex; + align-items: center; + justify-content: center; + gap: 0.625rem; + width: 100%; + padding: 0.9375rem 1.5rem; + border: none; + border-radius: 0.75rem; + background: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%); + background-size: 200% 200%; + color: #ffffff; + font-family: inherit; + font-size: 1rem; + font-weight: 600; + cursor: pointer; + overflow: hidden; + transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1); + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.1) inset, + 0 4px 20px rgba(59, 130, 246, 0.5), + 0 0 50px rgba(99, 102, 241, 0.4); + animation: submitEntrance 1s cubic-bezier(0.22, 1, 0.36, 1) 0.75s both; +} + +.login-submit::before { + content: ''; + position: absolute; + inset: 0; + background: linear-gradient( + 135deg, + rgba(255, 255, 255, 0) 0%, + rgba(255, 255, 255, 0.3) 50%, + rgba(255, 255, 255, 0) 100% + ); + transform: translateX(-100%) skewX(-25deg); + transition: transform 0.8s ease; +} + +.login-submit:hover:not(:disabled)::before { + transform: translateX(100%) skewX(-25deg); +} + +.login-submit::after { + content: ''; + position: absolute; + inset: 0; + background: radial-gradient( + circle at center, + rgba(255, 255, 255, 0.25) 0%, + transparent 70% + ); + opacity: 0; + transition: opacity 0.3s ease; +} + +.login-submit:active:not(:disabled)::after { + opacity: 1; +} + +.login-submit:hover:not(:disabled) { + transform: translateY(-3px); + background-position: 100% 0; + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.2) inset, + 0 10px 30px rgba(59, 130, 246, 0.6), + 0 0 80px rgba(99, 102, 241, 0.5); +} + +.login-submit:active:not(:disabled) { + transform: translateY(0) scale(0.96); + box-shadow: + 0 0 0 1px rgba(255, 255, 255, 0.1) inset, + 0 2px 10px rgba(59, 130, 246, 0.5), + 0 0 40px rgba(99, 102, 241, 0.3); + transition: all 0.1s ease; +} + +.login-submit:disabled { + opacity: 0.5; + cursor: not-allowed; + transform: none; +} + +.login-submit.loading { + pointer-events: none; +} + +.btn-shimmer { + position: absolute; + inset: 0; + background: linear-gradient( + 90deg, + transparent 0%, + rgba(255, 255, 255, 0.2) 50%, + transparent 100% + ); + animation: shimmer 3s ease-in-out infinite; +} + +@keyframes shimmer { + 0% { + transform: translateX(-100%); + } + 100% { + transform: translateX(100%); + } +} + +.btn-text { + position: relative; + z-index: 1; +} + +.btn-arrow { + position: relative; + z-index: 1; + display: inline-flex; + transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1); +} + +.login-submit:hover:not(:disabled) .btn-arrow { + transform: translateX(8px); +} + +.spinner { + width: 1.25rem; + height: 1.25rem; + border: 2.5px solid rgba(255, 255, 255, 0.2); + border-top-color: #ffffff; + border-radius: 50%; + animation: spin 0.7s linear infinite; + flex-shrink: 0; + position: relative; + z-index: 1; + box-shadow: 0 0 15px rgba(255, 255, 255, 0.4); +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +@keyframes fadeInUp { + from { + opacity: 0; + transform: translateY(24px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@keyframes logoEntrance { + from { + opacity: 0; + transform: scale(0.4) translateY(30px) rotate(-20deg); + } + to { + opacity: 1; + transform: scale(1) translateY(0) rotate(0deg); + } +} + +@keyframes cardEntrance { + from { + opacity: 0; + transform: translateY(60px) scale(0.8) rotateX(15deg); + } + to { + opacity: 1; + transform: translateY(0) scale(1) rotateX(0deg); + } +} + +@keyframes innerReveal { + from { + opacity: 0; + transform: scale(0.88); + } + to { + opacity: 1; + transform: scale(1); + } +} + +@keyframes shake { + 0%, + 100% { + transform: translate3d(0, 0, 0); + } + 12% { + transform: translate3d(-10px, 0, 0); + } + 24% { + transform: translate3d(10px, 0, 0); + } + 36% { + transform: translate3d(-8px, 0, 0); + } + 48% { + transform: translate3d(8px, 0, 0); + } + 60% { + transform: translate3d(-5px, 0, 0); + } + 72% { + transform: translate3d(5px, 0, 0); + } + 84% { + transform: translate3d(-2px, 0, 0); + } +} + +@media (max-width: 480px) { + .login-page { + padding: 1rem 0.75rem; + align-items: flex-start; + padding-top: 3.5rem; + } + + .login-card-inner { + padding: 2rem 1.25rem 1.5rem; + border-radius: 1.25rem; + } + + .login-logo-wrapper { + width: 80px; + height: 80px; + padding: 0.5rem; + } + + .login-title { + font-size: 1.375rem; + } + + .login-subtitle { + font-size: 0.875rem; + } + + .form-input { + padding: 0.75rem 2.5rem 0.75rem 0.75rem; + font-size: 0.875rem; + } + + .login-submit { + padding: 0.8125rem 1.25rem; + font-size: 0.9375rem; + } +} + +@media (min-width: 1024px) { + .login-page { + padding: 2rem; + } + + .login-card-inner { + padding: 3rem 2.5rem 2.5rem; + } +} + +@media (prefers-reduced-motion: reduce) { + .login-page, + .login-card, + .login-card-inner, + .login-header, + .login-logo-wrapper, + .login-form, + .form-options, + .login-submit, + .form-field { + animation: none !important; + transition: none !important; + } + + .blob { + animation: none !important; + } + + .login-submit::before, + .btn-shimmer, + .login-spotlight { + display: none; + } +} diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html new file mode 100644 index 0000000..e7baa5f --- /dev/null +++ b/src/app/pages/login/login.page.html @@ -0,0 +1,225 @@ + diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts new file mode 100644 index 0000000..8813bf3 --- /dev/null +++ b/src/app/pages/login/login.page.ts @@ -0,0 +1,196 @@ +import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { Router, NavigationEnd } from '@angular/router'; +import { filter, Subscription } from 'rxjs'; +import { AuthService, LoginResponse } from '../../services/auth/auth.service'; + +type LoginField = 'username' | 'password'; +type LoginErrors = Partial>; + +@Component({ + selector: 'app-login', + standalone: true, + imports: [CommonModule, FormsModule], + changeDetection: ChangeDetectionStrategy.OnPush, + templateUrl: './login.page.html', + styleUrl: './login.page.css', +}) +export class LoginPage { + private readonly authService = inject(AuthService); + private readonly router = inject(Router); + + readonly username = signal(''); + readonly password = signal(''); + readonly rememberMe = signal(false); + readonly showPassword = signal(false); + readonly isLoading = signal(false); + readonly errors = signal({}); + readonly generalError = signal(null); + readonly isShaking = signal(false); + readonly isEntering = signal(true); + readonly mousePosition = signal({ x: 0, y: 0 }); + + private routerSubscription?: Subscription; + + constructor() { + this.routerSubscription = this.router.events + .pipe(filter((event) => event instanceof NavigationEnd)) + .subscribe(() => { + this.resetForm(); + }); + } + + ngOnInit(): void { + this.restoreCredentials(); + setTimeout(() => this.isEntering.set(false), 1100); + } + + ngOnDestroy(): void { + this.routerSubscription?.unsubscribe(); + } + + private restoreCredentials(): void { + const saved = localStorage.getItem('remembered_credentials'); + if (saved) { + try { + const parsed = JSON.parse(saved); + if (parsed?.username) { + this.username.set(parsed.username); + this.rememberMe.set(true); + } + } catch { + // ignore corrupt data + } + } + } + + private saveCredentials(): void { + if (this.rememberMe()) { + localStorage.setItem('remembered_credentials', JSON.stringify({ username: this.username() })); + } else { + localStorage.removeItem('remembered_credentials'); + } + } + + onCardMouseMove(event: MouseEvent): void { + const rect = (event.currentTarget as HTMLElement).getBoundingClientRect(); + const x = ((event.clientX - rect.left) / rect.width) * 100; + const y = ((event.clientY - rect.top) / rect.height) * 100; + this.mousePosition.set({ x, y }); + } + + onCardMouseLeave(): void { + this.mousePosition.set({ x: 50, y: 50 }); + } + + onFieldBlur(field: LoginField): void { + this.validateField(field); + } + + private validateField(field: LoginField): void { + const currentErrors = { ...this.errors() }; + + switch (field) { + case 'username': + if (!this.username().trim()) { + currentErrors.username = 'نام کاربری الزامی است'; + } else { + delete currentErrors.username; + } + break; + case 'password': + if (!this.password()) { + currentErrors.password = 'رمز عبور الزامی است'; + } else { + delete currentErrors.password; + } + break; + } + + this.errors.set(currentErrors); + } + + validateAllFields(): LoginErrors { + const allErrors: LoginErrors = {}; + + if (!this.username().trim()) { + allErrors.username = 'نام کاربری الزامی است'; + } + + if (!this.password()) { + allErrors.password = 'رمز عبور الزامی است'; + } + + this.errors.set(allErrors); + return allErrors; + } + + onSubmit(): void { + const allErrors = this.validateAllFields(); + + if (Object.keys(allErrors).length > 0) { + this.triggerShake(); + return; + } + + this.isLoading.set(true); + this.generalError.set(null); + this.errors.set({}); + + const credentials = { + username: this.username().trim(), + password: this.password(), + }; + + this.authService.login(credentials).subscribe({ + next: (response: LoginResponse) => { + this.isLoading.set(false); + + if (!response?.user?.username) { + this.generalError.set('نام کاربری یا رمز عبور اشتباه است'); + this.triggerShake(); + return; + } + + this.saveCredentials(); + this.router.navigate(['/']); + }, + error: (err) => { + this.isLoading.set(false); + const message = + (err as any)?.error?.message || + (err as any)?.message || + 'خطا در اتصال به سرور. لطفاً دوباره تلاش کنید.'; + this.generalError.set(message); + this.triggerShake(); + }, + }); + } + + private triggerShake(): void { + this.isShaking.set(true); + setTimeout(() => this.isShaking.set(false), 700); + } + + togglePasswordVisibility(): void { + this.showPassword.update((v) => !v); + } + + onLogoClick(): void { + this.router.navigate(['/login']); + } + + private resetForm(): void { + this.username.set(''); + this.password.set(''); + this.rememberMe.set(false); + this.showPassword.set(false); + this.isLoading.set(false); + this.errors.set({}); + this.generalError.set(null); + this.isShaking.set(false); + this.isEntering.set(false); + this.mousePosition.set({ x: 50, y: 50 }); + } +} diff --git a/src/app/services/auth/auth.service.ts b/src/app/services/auth/auth.service.ts index 4c75444..6df61c2 100644 --- a/src/app/services/auth/auth.service.ts +++ b/src/app/services/auth/auth.service.ts @@ -1,65 +1,112 @@ import { Injectable } from '@angular/core'; -import { Observable, BehaviorSubject, forkJoin, of } from 'rxjs'; +import { Observable, BehaviorSubject, forkJoin, of, throwError } from 'rxjs'; import { tap, map, switchMap, catchError } from 'rxjs/operators'; import { HttpService } from '../http-request/http.service'; -interface ApiResult { - hasError: boolean; - messages: string[]; - result: T; -} - -interface LoginResponse { - auth: boolean; - token: string; +export interface AuthUser { + id: string; username: string; + role: string; + organization_id: string; } -interface LoginResult extends ApiResult { - licenseValid?: boolean; +export interface LoginResponse { + user: AuthUser; + csrf_token: string; + expires_at: string; +} + +export interface CurrentUserResponse { + user: AuthUser; + csrf_token: string; + expires_at: string; } @Injectable({ providedIn: 'root', }) export class AuthService { - public currentUserSubject = new BehaviorSubject( - localStorage.getItem('username'), - ); + public currentUserSubject = new BehaviorSubject(null); + private csrfToken: string | null = null; + constructor( private httpService: HttpService, ) { - let previousUser: string | null = this.currentUserSubject.value; - this.currentUserSubject.subscribe((username) => { - if (username !== previousUser) { - previousUser = username; + const savedUser = localStorage.getItem('current_user'); + const savedCsrf = localStorage.getItem('csrf_token'); + if (savedUser) { + try { + this.currentUserSubject.next(JSON.parse(savedUser)); + } catch { + // ignore corrupt data } - }); + } + if (savedCsrf) { + this.csrfToken = savedCsrf; + } } login(credentials: { username: string; password: string; - rememberMe: boolean; - }): Observable { - return this.httpService.post('users/login', credentials).pipe( - tap((response: ApiResult) => { - if (!response.hasError && response.result?.auth) { - localStorage.setItem('access_token', response.result.token); - localStorage.setItem('username', response.result.username); - this.currentUserSubject.next(response.result.username); - } + }): Observable { + return this.httpService.postRaw('v1/auth/login', credentials).pipe( + tap((response) => { + this.currentUserSubject.next(response.user); + this.csrfToken = response.csrf_token; + localStorage.setItem('current_user', JSON.stringify(response.user)); + localStorage.setItem('csrf_token', response.csrf_token); + }), + catchError((err) => { + this.clearAuth(); + return throwError(() => err); }), ); } - logout(): void { - localStorage.removeItem('access_token'); - localStorage.removeItem('username'); - this.currentUserSubject.next(null); + logout(): Observable { + const headers: Record = {}; + if (this.csrfToken) { + headers['X-CSRF-Token'] = this.csrfToken; + } + return this.httpService.postRaw('v1/auth/logout', {}, { headers }).pipe( + tap(() => { + this.clearAuth(); + }), + catchError((err) => { + this.clearAuth(); + return throwError(() => err); + }), + ); + } + + getCurrentUser(): Observable { + return this.httpService.getRaw('v1/me').pipe( + tap((response) => { + this.currentUserSubject.next(response.user); + this.csrfToken = response.csrf_token; + localStorage.setItem('current_user', JSON.stringify(response.user)); + localStorage.setItem('csrf_token', response.csrf_token); + }), + ); } isAuthenticated(): boolean { - return !!localStorage.getItem('access_token'); + return !!this.currentUserSubject.value; + } + + getCurrentUserValue(): AuthUser | null { + return this.currentUserSubject.value; + } + + getCsrfToken(): string | null { + return this.csrfToken; + } + + private clearAuth(): void { + this.currentUserSubject.next(null); + this.csrfToken = null; + localStorage.removeItem('current_user'); + localStorage.removeItem('csrf_token'); } } diff --git a/src/app/services/http-request/http.service.ts b/src/app/services/http-request/http.service.ts index d40cdfa..01c7bba 100644 --- a/src/app/services/http-request/http.service.ts +++ b/src/app/services/http-request/http.service.ts @@ -94,6 +94,13 @@ export class HttpService { return throwError(() => new Error('Unauthorized')); } + if (error.status === 429 && !skipToast) { + if (this.shouldDisplayMessage('تلاش‌های بیش از حد مجاز. لطفاً بعداً تلاش کنید.')) { + this.toast.warning('تلاش‌های بیش از حد مجاز. لطفاً بعداً تلاش کنید.'); + } + return throwError(() => new Error('RATE_LIMITED')); + } + if (error.status === 422 && error.error && !skipToast) { try { const apiError = error.error as ApiResult; @@ -254,6 +261,24 @@ export class HttpService { ); } + postRaw(endpoint: string, data: any, options: HttpOptions = {}): Observable { + const url = `${this.baseUrl}/${endpoint}`; + const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders(); + return this.http.post(url, data, { + headers, + params: options.params, + }); + } + + getRaw(endpoint: string, options: HttpOptions = {}): Observable { + const url = `${this.baseUrl}/${endpoint}`; + const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders(); + return this.http.get(url, { + headers, + params: options.params, + }); + } + put(endpoint: string, data: any, options: HttpOptions = {}): Observable> { const url = `${this.baseUrl}/${endpoint}`; return this.http