diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..6c5df2a Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index aa9ec12..d244c8a 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,12 @@ "@angular/cli": "^20.0.3", "@angular/compiler-cli": "^20.0.4", "@types/jasmine": "~5.1.0", - "jasmine-core": "~5.1.0", + "jasmine-core": "~5.10.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", - "typescript": "~5.8.3" + "typescript": "~5.9.0" } } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 1ccabc6..a7f28f6 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, withDebugTracing()), + provideRouter(routes), provideHttpClient(withInterceptors([httpInterceptor])), ], }; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index dc084f2..ee8aad5 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,5 +1,6 @@ import { Routes } from '@angular/router'; import { authGuard } from './service/auth.guard'; +import NotFoundComponent from './component/not-found/not-found.component'; export const routes: Routes = [ { @@ -32,4 +33,12 @@ 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 d6df24b..2b92580 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 } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, @@ -7,23 +7,30 @@ import { } from '@angular/forms'; import AuthService from '../../../service/auth.service'; import { AuthResponse, Token } from '../../../models'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'app-login', imports: [ReactiveFormsModule], templateUrl: './login.component.html', }) -export default class LoginComponent { +export default class LoginComponent implements OnInit { 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); @@ -34,7 +41,7 @@ export default class LoginComponent { localStorage.setItem('access_token', r.accessToken); localStorage.setItem('refresh_token', r.refreshToken); - this.router.navigate(['dashboard']); + this.router.navigate([this.returnUrl]); }); } } diff --git a/src/app/component/not-found/not-found.component.ts b/src/app/component/not-found/not-found.component.ts new file mode 100644 index 0000000..12b55ff --- /dev/null +++ b/src/app/component/not-found/not-found.component.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-not-found', + template: '