From e3d94b64a376516618a98597140154ae988573c6 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 15 Sep 2025 21:33:38 +0200 Subject: [PATCH] fix: `token` / `error` are cleared correcly on error / success * also added a delay to make the disabling of the form visible --- src/app/services/auth.service.ts | 3 ++- src/app/store/login.reducers.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 3b4d86a..9c39495 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -1,6 +1,7 @@ import { inject, Injectable } from '@angular/core'; import { Router } from "@angular/router"; import { Observable, of, throwError } from 'rxjs'; +import { delay } from 'rxjs/operators'; @Injectable({ providedIn: 'root' @@ -16,7 +17,7 @@ export class AuthService { return throwError(() => new Error('Simulierter Fehler im Service')); } this.username = username; - return of(username); + return of(username).pipe(delay(1000)); } assertUserIsKnown(): void { diff --git a/src/app/store/login.reducers.ts b/src/app/store/login.reducers.ts index 5d495e7..951624a 100644 --- a/src/app/store/login.reducers.ts +++ b/src/app/store/login.reducers.ts @@ -15,6 +15,6 @@ const initialState: State = { export const loginReducers = createReducer(initialState, on(login, state => ({ ...state, isLoading: true })), - on(loginSuccess, (state, { token }) => ({ ...state, token, isLoading: false })), - on(loginFailure, (state, { error }) => ({ ...state, error, isLoading: false })) + on(loginSuccess, (state, { token }) => ({ ...state, token, error: null, isLoading: false })), + on(loginFailure, (state, { error }) => ({ ...state, token: null, error, isLoading: false })) ); -- 2.39.5