From 2fefacf53d2bdb938467528ff8aa03d4a25d72eb Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 15 Sep 2025 20:53:06 +0200 Subject: [PATCH] implemented a faked authentication, that fails in 30% --- src/app/services/auth.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index dfd2858..3b4d86a 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -1,6 +1,6 @@ import { inject, Injectable } from '@angular/core'; import { Router } from "@angular/router"; -import { Observable, of } from 'rxjs'; +import { Observable, of, throwError } from 'rxjs'; @Injectable({ providedIn: 'root' @@ -11,6 +11,11 @@ export class AuthService { private username : string|undefined; login(username : string, password : string) : Observable { + const shouldFail = Math.random() < 0.3; // 30% Fehlerchance + if (shouldFail) { + return throwError(() => new Error('Simulierter Fehler im Service')); + } + this.username = username; return of(username); } -- 2.39.5