WIP: vollständiger, aber ggf. unnötig
authorKai Moritz <kai@juplo.de>
Sun, 7 Sep 2025 11:28:07 +0000 (13:28 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 7 Sep 2025 11:28:07 +0000 (13:28 +0200)
src/app/services/auth.service.ts

index 26bf98e..22c9d0e 100644 (file)
@@ -1,6 +1,6 @@
 import { Injectable } from '@angular/core';
 import { Router } from "@angular/router";
-import { of } from 'rxjs';
+import { Observable, of, throwError } from 'rxjs';
 
 @Injectable({
   providedIn: 'root'
@@ -10,10 +10,10 @@ export class AuthService {
 
   constructor(private router : Router) { }
 
-  login(username : string, password : string) {
+  login(username : string, password : string) : Observable<any> {
     const shouldFail = Math.random() < 0.3; // 30% Fehlerchance
     if (shouldFail) {
-      throw new Error('Simulierter Fehler im Service');
+      return throwError(() => new Error('Simulierter Fehler im Service'));
     }
     this.username = username;
     return of(username);