Fix user errors for login auth

This commit is contained in:
2025-07-17 18:09:23 -07:00
parent da04fa7a5b
commit d59d476a6e
3 changed files with 15 additions and 27 deletions
@@ -45,12 +45,7 @@ export class LoginComponent {
this.errorMsgs.push("Waiting for response from server"); this.errorMsgs.push("Waiting for response from server");
this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe( this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe(
data => { data => {
if (data.error.length === 0){
this.router.navigate([this.returnURL]); this.router.navigate([this.returnURL]);
}else{
this.errorMsgs.pop();
this.errorMsgs.push(data.error);
}
} }
) )
} }
@@ -68,14 +68,9 @@ export class RegisterComponent {
}); });
this.http.post<Account>( "api/account/register", body, { headers } ).subscribe({ this.http.post<Account>( "api/account/register", body, { headers } ).subscribe({
next: async (data) => { next: async (data) => {
if (data.error.length === 0){
this.errorMsgs = ["Account Created"]; this.errorMsgs = ["Account Created"];
await this.sleep(3000); await this.sleep(3000);
this.router.navigate([this.returnURL]); this.router.navigate([this.returnURL]);
}else{
this.errorMsgs = [];
this.errorMsgs.push(data.error);
}
}, },
error: err => { error: err => {
console.log("HTTP Error Signing In: ", err); console.log("HTTP Error Signing In: ", err);
@@ -24,10 +24,8 @@ export class Authentication{
let sub = this.http.post<Account>( "api/account/login", body, { headers } ); let sub = this.http.post<Account>( "api/account/login", body, { headers } );
sub.subscribe({ sub.subscribe({
next: data => { next: data => {
if (data.error.length === 0){
this._user.next(data); this._user.next(data);
this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session); this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session);
}
}, },
error: err => { error: err => {
console.log("HTTP Error Signing In: ", err); console.log("HTTP Error Signing In: ", err);