Tweaked the SessionManager's IsSessionTokenValid function to accept a connection string to standardize the interfaces on all the SessionManager functions.

This commit is contained in:
2021-03-10 21:52:52 -06:00
parent baf2518fe8
commit 9b283b31f4
7 changed files with 13 additions and 9 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ namespace SecureCore.Controllers
try
{
if (SessionManager.IsSessionTokenValid(HttpContext))
if (SessionManager.IsSessionTokenValid(HttpContext, connectionString))
return Ok("Logged in\n");
//Verify that the username provided is valid, i.e. no whitespace, special characters, etc.
@@ -168,7 +168,7 @@ namespace SecureCore.Controllers
PasswordManager.InsertPasswordResetRequest(email, token, DateTime.Now.AddHours(1), agent, ip, connectionString);
token = HttpUtility.UrlEncode(token);
//TODO: Allow the admin to configure the address that this function creates when doing password resets.
//TODO: Email the link to the supplied email.
return Ok($"192.168.255.200:5000/auth/ResetPassword?token={token}{Environment.NewLine}");
}
catch(Exception e)
+6 -2
View File
@@ -24,7 +24,9 @@ namespace SecureCore.Controllers
[HttpGet]
public IActionResult Get()
{
if(SessionManager.IsSessionTokenValid(HttpContext))
AppSettingsManager.TryGetConnectionString("MainDataConnectionString", out string connectionString);
if (SessionManager.IsSessionTokenValid(HttpContext, connectionString))
return Ok(DataService.Get());
else
return Unauthorized();
@@ -33,7 +35,9 @@ namespace SecureCore.Controllers
[HttpGet("{id}", Name = "Get")]
public IActionResult Get(int id)
{
if (SessionManager.IsSessionTokenValid(HttpContext))
AppSettingsManager.TryGetConnectionString("MainDataConnectionString", out string connectionString);
if (SessionManager.IsSessionTokenValid(HttpContext, connectionString))
return Ok(DataService.GetById(id));
else
return Unauthorized();