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`
This commit is contained in:
@@ -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<any>;
|
||||
@@ -254,6 +261,24 @@ export class HttpService {
|
||||
);
|
||||
}
|
||||
|
||||
postRaw<T>(endpoint: string, data: any, options: HttpOptions = {}): Observable<T> {
|
||||
const url = `${this.baseUrl}/${endpoint}`;
|
||||
const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders();
|
||||
return this.http.post<T>(url, data, {
|
||||
headers,
|
||||
params: options.params,
|
||||
});
|
||||
}
|
||||
|
||||
getRaw<T>(endpoint: string, options: HttpOptions = {}): Observable<T> {
|
||||
const url = `${this.baseUrl}/${endpoint}`;
|
||||
const headers = options.headers ? new HttpHeaders(options.headers) : new HttpHeaders();
|
||||
return this.http.get<T>(url, {
|
||||
headers,
|
||||
params: options.params,
|
||||
});
|
||||
}
|
||||
|
||||
put<T>(endpoint: string, data: any, options: HttpOptions = {}): Observable<ApiResult<T>> {
|
||||
const url = `${this.baseUrl}/${endpoint}`;
|
||||
return this.http
|
||||
|
||||
Reference in New Issue
Block a user