From 792e0abba379b0347c1639a6ef769c92965f512d Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Thu, 17 Jul 2025 18:18:27 -0700 Subject: [PATCH] Authentication works as designed --- .../src/app/pages/account/login/login.component.ts | 9 ++++++--- .../src/app/pages/account/register/register.component.ts | 2 +- src/Client/src/app/services/Authentication.ts | 2 +- src/Server/Controllers/AuthenticationController.cs | 4 ++-- 4 files changed, 10 insertions(+), 7 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 1420e0f..751f5ed 100644 --- a/src/Client/src/app/pages/account/login/login.component.ts +++ b/src/Client/src/app/pages/account/login/login.component.ts @@ -43,10 +43,13 @@ export class LoginComponent { } this.errorMsgs.push("Waiting for response from server"); - this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe( - data => { + this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe({ + next: data => { this.router.navigate([this.returnURL]); + }, + error: err => { + this.errorMsgs = [ err.error ]; } - ) + }) } } \ No newline at end of file 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 154bdf0..321c552 100644 --- a/src/Client/src/app/pages/account/register/register.component.ts +++ b/src/Client/src/app/pages/account/register/register.component.ts @@ -73,7 +73,7 @@ export class RegisterComponent { this.router.navigate([this.returnURL]); }, error: err => { - console.log("HTTP Error Signing In: ", err); + this.errorMsgs = [ err.error ] } }); } diff --git a/src/Client/src/app/services/Authentication.ts b/src/Client/src/app/services/Authentication.ts index dfb95c9..4e7c8a9 100644 --- a/src/Client/src/app/services/Authentication.ts +++ b/src/Client/src/app/services/Authentication.ts @@ -28,7 +28,7 @@ export class Authentication{ this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session); }, error: err => { - console.log("HTTP Error Signing In: ", err); + console.log("HTTP Error Signing In: ", err.error); } }); return sub; diff --git a/src/Server/Controllers/AuthenticationController.cs b/src/Server/Controllers/AuthenticationController.cs index 463ab62..3971608 100755 --- a/src/Server/Controllers/AuthenticationController.cs +++ b/src/Server/Controllers/AuthenticationController.cs @@ -51,7 +51,7 @@ namespace BoredCareers.Controllers { } else { test.CurrentPasswordAttempts += 1; await _databaseService.SetAccount(test); - return Ok(new Account() { ID = -1, UserName = "Wrong Password" }); + return NotFound("Wrong Password"); } } else { await SendVerify(test.UserName); @@ -92,7 +92,7 @@ namespace BoredCareers.Controllers { } } catch (Exception ex) { Console.WriteLine("Register Error: " + ex.Message); - return NotFound(); + return NotFound("An internal server error has occured"); } }