From d59d476a6e34f66a8ba64d98b6a8d114efff5ccd Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Thu, 17 Jul 2025 18:09:23 -0700 Subject: [PATCH] Fix user errors for login auth --- .../pages/account/login/login.component.ts | 7 +---- .../account/register/register.component.ts | 29 ++++++++----------- src/Client/src/app/services/Authentication.ts | 6 ++-- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/Client/src/app/pages/account/login/login.component.ts b/src/Client/src/app/pages/account/login/login.component.ts index d0e23a9..1420e0f 100644 --- a/src/Client/src/app/pages/account/login/login.component.ts +++ b/src/Client/src/app/pages/account/login/login.component.ts @@ -45,12 +45,7 @@ export class LoginComponent { this.errorMsgs.push("Waiting for response from server"); this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe( data => { - if (data.error.length === 0){ - this.router.navigate([this.returnURL]); - }else{ - this.errorMsgs.pop(); - this.errorMsgs.push(data.error); - } + this.router.navigate([this.returnURL]); } ) } diff --git a/src/Client/src/app/pages/account/register/register.component.ts b/src/Client/src/app/pages/account/register/register.component.ts index 5a7b7aa..154bdf0 100644 --- a/src/Client/src/app/pages/account/register/register.component.ts +++ b/src/Client/src/app/pages/account/register/register.component.ts @@ -60,26 +60,21 @@ export class RegisterComponent { // Send to server and wait for response this.errorMsgs.push("Waiting for response from server"); const body = new HttpParams() - .set("Email", this.email) - .set("UserName", this.userName) - .set("PasswordHash", this.passwordHash); + .set("Email", this.email) + .set("UserName", this.userName) + .set("PasswordHash", this.passwordHash); const headers = new HttpHeaders({ - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Type': 'application/x-www-form-urlencoded' }); this.http.post( "api/account/register", body, { headers } ).subscribe({ - next: async (data) => { - if (data.error.length === 0){ - this.errorMsgs = ["Account Created"]; - await this.sleep(3000); - this.router.navigate([this.returnURL]); - }else{ - this.errorMsgs = []; - this.errorMsgs.push(data.error); - } - }, - error: err => { - console.log("HTTP Error Signing In: ", err); - } + next: async (data) => { + this.errorMsgs = ["Account Created"]; + await this.sleep(3000); + this.router.navigate([this.returnURL]); + }, + error: err => { + console.log("HTTP Error Signing In: ", err); + } }); } } \ No newline at end of file diff --git a/src/Client/src/app/services/Authentication.ts b/src/Client/src/app/services/Authentication.ts index ca3b9ae..dfb95c9 100644 --- a/src/Client/src/app/services/Authentication.ts +++ b/src/Client/src/app/services/Authentication.ts @@ -24,10 +24,8 @@ export class Authentication{ let sub = this.http.post( "api/account/login", body, { headers } ); sub.subscribe({ next: data => { - if (data.error.length === 0){ - this._user.next(data); - this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session); - } + this._user.next(data); + this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session); }, error: err => { console.log("HTTP Error Signing In: ", err);