feat: Made login errors download from server

This commit is contained in:
2025-05-16 00:38:59 +02:00
parent 6ab3598d38
commit 90d5b5da1c
2 changed files with 3 additions and 14 deletions

View File

@@ -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() { submit() {
const val = this.form.value const val = this.form.value
this.ac.login(val.uname, val.pass).pipe(catchError((err,caught)=>{ 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)) return throwError(() => new Error(err.message))
})).subscribe((data) => { })).subscribe((data) => {
this.ls.loggedIn = true this.ls.loggedIn = true

View File

@@ -1,3 +1,4 @@
export interface Status { export interface Status {
status: number status: number,
message?: string
} }