diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 6c5df2a..0000000 Binary files a/bun.lockb and /dev/null differ diff --git a/src/app/app.config.ts b/src/app/app.config.ts index a7f28f6..1ccabc6 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -8,7 +8,7 @@ import { httpInterceptor } from './service/http.interceptor'; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), - provideRouter(routes), + provideRouter(routes, withDebugTracing()), provideHttpClient(withInterceptors([httpInterceptor])), ], }; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index ee8aad5..dc084f2 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,6 +1,5 @@ import { Routes } from '@angular/router'; import { authGuard } from './service/auth.guard'; -import NotFoundComponent from './component/not-found/not-found.component'; export const routes: Routes = [ { @@ -33,12 +32,4 @@ export const routes: Routes = [ ], canActivate: [authGuard], }, - { - path: '404', - component: NotFoundComponent, - }, - { - path: '**', - redirectTo: '404', - }, ]; diff --git a/src/app/component/auth/login/login.component.ts b/src/app/component/auth/login/login.component.ts index 2b92580..d6df24b 100644 --- a/src/app/component/auth/login/login.component.ts +++ b/src/app/component/auth/login/login.component.ts @@ -1,4 +1,4 @@ -import { Component, inject, OnInit } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { FormBuilder, FormGroup, @@ -7,30 +7,23 @@ import { } from '@angular/forms'; import AuthService from '../../../service/auth.service'; import { AuthResponse, Token } from '../../../models'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Router } from '@angular/router'; @Component({ selector: 'app-login', imports: [ReactiveFormsModule], templateUrl: './login.component.html', }) -export default class LoginComponent implements OnInit { +export default class LoginComponent { fb: FormBuilder = inject(FormBuilder); authService: AuthService = inject(AuthService); router: Router = inject(Router); - route: ActivatedRoute = inject(ActivatedRoute); form: FormGroup = this.fb.group({ username: [null, [Validators.required]], password: [null, [Validators.required]], }); - returnUrl: string | undefined; - - ngOnInit(): void { - this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/dashboard'; - } - login() { if (this.form.invalid) { console.log(this.form.errors); @@ -41,7 +34,7 @@ export default class LoginComponent implements OnInit { localStorage.setItem('access_token', r.accessToken); localStorage.setItem('refresh_token', r.refreshToken); - this.router.navigate([this.returnUrl]); + this.router.navigate(['dashboard']); }); } } diff --git a/src/app/component/not-found/not-found.component.ts b/src/app/component/not-found/not-found.component.ts deleted file mode 100644 index 12b55ff..0000000 --- a/src/app/component/not-found/not-found.component.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-not-found', - template: '

404 Not Found

', - standalone: true, -}) -export default class NotFoundComponent {} diff --git a/src/app/component/users/users.component.ts b/src/app/component/users/users.component.ts index 08ef65d..6eabb1a 100644 --- a/src/app/component/users/users.component.ts +++ b/src/app/component/users/users.component.ts @@ -1,19 +1,8 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, inject, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; @Component({ selector: 'app-users', imports: [], templateUrl: './users.component.html', }) -export default class UsersComponent implements OnInit { - private client = inject(HttpClient); - ngOnInit() { - console.log('AHHHH'); - console.log('AHHHHH'); - - this.client.get('https://dummyjson.com/users', {}).subscribe((response) => { - console.log(response); - }); - } -} +export default class UsersComponent {} diff --git a/src/app/service/auth.guard.ts b/src/app/service/auth.guard.ts index c0f4d0e..d7ebe50 100644 --- a/src/app/service/auth.guard.ts +++ b/src/app/service/auth.guard.ts @@ -1,4 +1,4 @@ -import { CanActivateFn, Router } from '@angular/router'; +import { CanActivateFn } from '@angular/router'; import { inject } from '@angular/core'; import { HttpClient, @@ -8,9 +8,7 @@ import { import { catchError, map, of } from 'rxjs'; import { User } from '../models'; -export const authGuard: CanActivateFn = (route, state) => { - const router = inject(Router); - +export const authGuard: CanActivateFn = () => { return inject(HttpClient) .get('https://dummyjson.com/auth/me', { observe: 'response' }) .pipe( @@ -20,9 +18,6 @@ export const authGuard: CanActivateFn = (route, state) => { }), catchError((err: HttpErrorResponse) => { console.log(err); - router.navigate(['/auth/login'], { - queryParams: { returnUrl: state.url }, - }); return of(false); }), ); diff --git a/src/app/service/http.interceptor.ts b/src/app/service/http.interceptor.ts index 594b8ae..349afda 100644 --- a/src/app/service/http.interceptor.ts +++ b/src/app/service/http.interceptor.ts @@ -8,10 +8,6 @@ export const httpInterceptor: HttpInterceptorFn = ( req: HttpRequest, next: HttpHandlerFn, ) => { - if (req.url.includes('/auth/login') || req.url.includes('/auth/register')) { - return next(req); - } - return next( req.clone({ setHeaders: {