From 90d5b5da1ce0d1ece8bc5088eff77ce078492707 Mon Sep 17 00:00:00 2001 From: Jan Szumotalski Date: Fri, 16 May 2025 00:38:59 +0200 Subject: [PATCH] feat: Made login errors download from server --- src/app/login/login.component.ts | 14 +------------- src/app/types/status.ts | 3 ++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index c5315ce..257917e 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -26,22 +26,10 @@ export class LoginComponent implements OnInit { } } - errorParser(err: any) { - switch (err.status) { - case 401: - this.error = "Zła nazwa użytkownika lub hasło" - break; - - default: - this.error = "Nieznany błąd" - break; - } - } - submit() { const val = this.form.value this.ac.login(val.uname, val.pass).pipe(catchError((err,caught)=>{ - this.errorParser(err) + this.error = err.error.message return throwError(() => new Error(err.message)) })).subscribe((data) => { this.ls.loggedIn = true diff --git a/src/app/types/status.ts b/src/app/types/status.ts index dd47250..faf2ff4 100644 --- a/src/app/types/status.ts +++ b/src/app/types/status.ts @@ -1,3 +1,4 @@ export interface Status { - status: number + status: number, + message?: string }