Refactor permission handling and authentication services

Replaced `PermissionClaim` enum with an OpenAPI-defined schema `PermissionClaimDto` for consistency across frontend and backend. Refactored authentication flow to utilize `AuthService` on the frontend, consolidating JWT handling logic. Removed redundant methods like `saveJwt` and integrated robust permission management throughout the application.
This commit is contained in:
2025-06-21 23:15:46 +02:00
parent 07646e8c42
commit 32a454c034
8 changed files with 144 additions and 60 deletions
+4 -15
View File
@@ -5,9 +5,8 @@ import {MatButtonModule} from '@angular/material/button';
import {MatInputModule} from '@angular/material/input';
import {MatFormFieldModule} from '@angular/material/form-field';
import {NgIf} from '@angular/common';
import {LoginService} from '../../api';
import {MatSnackBar} from '@angular/material/snack-bar';
import {CookieService} from 'ngx-cookie-service';
import {AuthService} from '../services/auth.service';
@Component({
selector: 'app-login',
@@ -31,9 +30,8 @@ export class LoginDialogComponent {
constructor(
public dialogRef: MatDialogRef<LoginDialogComponent>,
private fb: FormBuilder,
private loginService: LoginService,
private snackBar: MatSnackBar,
private cookieService: CookieService
private authService: AuthService,
private snackBar: MatSnackBar
) {
this.loginForm = this.fb.group({
code: ['', [
@@ -55,9 +53,8 @@ export class LoginDialogComponent {
return;
}
this.snackBar.open('Logging in...', '', {duration: 2000});
this.loginService.login(this.loginForm.value.code).subscribe({
this.authService.login(this.loginForm.value.code).subscribe({
next: (jwt) => {
this.saveJwt(jwt as JsonWebKey);
this.dialogRef.close(jwt);
},
error: () => {
@@ -68,14 +65,6 @@ export class LoginDialogComponent {
});
}
private saveJwt(jwt: JsonWebKey) {
this.cookieService.set('jwt', jwt.toString(), {
path: '/',
secure: true,
sameSite: 'Strict'
});
}
public formHasError() {
return this.loginForm.get('code')?.hasError('required');
}