UI #4

Merged
derek merged 26 commits from UI into main 2025-07-18 19:59:18 -07:00
Showing only changes of commit 91b39504b6 - Show all commits
@@ -47,7 +47,7 @@ namespace BoredCareers.Controllers {
IsPersistent = StayLoggedIn, // Is set from the StayLoggedIn IsPersistent = StayLoggedIn, // Is set from the StayLoggedIn
} }
); );
return test; return Ok(test);
} else { } else {
test.CurrentPasswordAttempts += 1; test.CurrentPasswordAttempts += 1;
await _databaseService.SetAccount(test); await _databaseService.SetAccount(test);
@@ -61,7 +61,7 @@ namespace BoredCareers.Controllers {
return NotFound("Account Not Found"); return NotFound("Account Not Found");
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("Login Error: " + ex.Message); Console.WriteLine("Login Error: " + ex.Message);
return NotFound(); return NotFound("An internal server error has occured");
} }
} }
@@ -110,10 +110,10 @@ namespace BoredCareers.Controllers {
return Ok(); return Ok();
} }
} }
return NotFound(); return NotFound("Not logged in");
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("ChangePassword Error: " + ex.Message); Console.WriteLine("ChangePassword Error: " + ex.Message);
return NotFound(); return NotFound("An internal server error has occured");
} }
} }
@@ -128,10 +128,10 @@ namespace BoredCareers.Controllers {
await _databaseService.SetAccount(user); await _databaseService.SetAccount(user);
return Ok(); return Ok();
} }
return NotFound(); return NotFound("Not logged in");
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("ToggleAccountLock Error: " + ex.Message); Console.WriteLine("ToggleAccountLock Error: " + ex.Message);
return NotFound(); return NotFound("An internal server error has occured");
} }
} }
@@ -142,10 +142,10 @@ namespace BoredCareers.Controllers {
if (isLoggedIn()) { if (isLoggedIn()) {
return Ok(await getLoggedInUser()); return Ok(await getLoggedInUser());
} }
return NotFound(); return NotFound("Not logged in");
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("Get Error: " + ex); Console.WriteLine("Get Error: " + ex);
return NotFound(); return NotFound("An internal server error has occured");
} }
} }
@@ -168,7 +168,7 @@ namespace BoredCareers.Controllers {
if (_emailContext._SentEmails.ContainsKey(key)) { if (_emailContext._SentEmails.ContainsKey(key)) {
DateTime PreviousSentTime = _emailContext._SentEmails.GetValueOrDefault(key); DateTime PreviousSentTime = _emailContext._SentEmails.GetValueOrDefault(key);
if (PreviousSentTime.AddMinutes(5) > DateTime.Now) { if (PreviousSentTime.AddMinutes(5) > DateTime.Now) {
return "Cannot sent another verify email until 5 minutes has elapsed "; return NotFound("Cannot sent another verify email until 5 minutes has elapsed");
} }
else { else {
_emailContext._SentEmails.Remove(key); _emailContext._SentEmails.Remove(key);
@@ -186,11 +186,11 @@ namespace BoredCareers.Controllers {
string result = _emailContext.Send(test.Email, EmailService.VerifyEmailSubject, EmailContents); string result = _emailContext.Send(test.Email, EmailService.VerifyEmailSubject, EmailContents);
_emailContext._SentEmails.Add(key, DateTime.Now); _emailContext._SentEmails.Add(key, DateTime.Now);
return result; return Ok(result);
} }
return "Account not found"; return NotFound("Account not found");
} catch (Exception) { } catch (Exception) {
return "The connection couldn't be established to the email server"; return NotFound("An internal server error has occured");
} }
} }
@@ -204,12 +204,12 @@ namespace BoredCareers.Controllers {
test.EmailToken = ""; test.EmailToken = "";
test.EmailVerified = true; test.EmailVerified = true;
await _databaseService.SetAccount(test); await _databaseService.SetAccount(test);
return true; return Ok(true);
} }
} }
return false; return NotFound("Account not found or token is invalid");;
} catch { } catch {
return false; return NotFound("An internal server error has occured");
} }
} }
@@ -222,7 +222,7 @@ namespace BoredCareers.Controllers {
if (_emailContext._SentEmails.ContainsKey(key)) { if (_emailContext._SentEmails.ContainsKey(key)) {
DateTime PreviousSentTime = _emailContext._SentEmails.GetValueOrDefault(key); DateTime PreviousSentTime = _emailContext._SentEmails.GetValueOrDefault(key);
if (PreviousSentTime.AddMinutes(5) > DateTime.Now) { if (PreviousSentTime.AddMinutes(5) > DateTime.Now) {
return "Cannot sent another reset requests until 5 minutes has elapsed"; return NotFound("Cannot sent another reset requests until 5 minutes has elapsed");
} }
else { else {
_emailContext._SentEmails.Remove(key); _emailContext._SentEmails.Remove(key);
@@ -240,12 +240,12 @@ namespace BoredCareers.Controllers {
string result = _emailContext.Send(test.Email, EmailService.VerifyEmailSubject, EmailContents); string result = _emailContext.Send(test.Email, EmailService.VerifyEmailSubject, EmailContents);
_emailContext._SentEmails.Add(key, DateTime.Now); _emailContext._SentEmails.Add(key, DateTime.Now);
return result; return Ok(result);
} }
return "Account Not Found"; return NotFound("Account Not Found");
} catch (Exception e) { } catch (Exception e) {
Console.WriteLine("EmailService Error: " + e.ToString()); Console.WriteLine("EmailService Error: " + e.ToString());
return "The connection couldn't be established to the email server"; return NotFound("An internal server error has occured");
} }
} }
@@ -261,12 +261,12 @@ namespace BoredCareers.Controllers {
test.EmailToken = ""; test.EmailToken = "";
test.PasswordHash = BCrypt.Net.BCrypt.HashPassword(NewPassword); test.PasswordHash = BCrypt.Net.BCrypt.HashPassword(NewPassword);
await _databaseService.SetAccount(test); await _databaseService.SetAccount(test);
return true; return Ok(true);
} }
} }
return false; return NotFound("Account not found or reset token is bad");
} catch { } catch {
return false; return NotFound("An internal server error has occured");
} }
} }
@@ -281,10 +281,10 @@ namespace BoredCareers.Controllers {
return Ok(); return Ok();
} }
} }
return NotFound(); return NotFound("User is not logged in");
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine("Delete Error: " + ex.Message); Console.WriteLine("Delete Error: " + ex.Message);
return NotFound(); return NotFound("An internal server error has occured");
} }
} }