Updated the PasswordManager to check for a min password length as that might be a tad important.

This commit is contained in:
2021-01-12 21:28:11 -06:00
parent 4e25410d30
commit 4721a70ea7
4 changed files with 11 additions and 11 deletions
+6 -8
View File
@@ -22,17 +22,15 @@ namespace SecureCore.Controllers
//NOTE: password length should be at most 64 - 128 characters long.
//Very the user has login data.
//if (!UserDataService.UserHasLoginData(info.UserName)) return Unauthorized("User doesn't have login creds");
if (info.Password.Length > PasswordManager.MaxPasswordLength) return Unauthorized($"Password exceeds maxium length of {PasswordManager.MaxPasswordLength} characters.");
var result = UserDataService.UserNameIsValid(info.UserName);
if (!result.IsValid) return Unauthorized(result.Message);
if (HttpContext.Request.Cookies.ContainsKey("Session"))
{
if(UserDataService.IsSessionTokenValid(HttpContext.Request.Cookies["Session"]))//, info.UserName))
return Ok($"Session is live{Environment.NewLine}");
}
//if (HttpContext.Request.Cookies.ContainsKey("Session"))
//{
// if(UserDataService.IsSessionTokenValid(HttpContext.Request.Cookies["Session"]))//, info.UserName))
// return Ok($"Session is live{Environment.NewLine}");
//}
var (password, salt) = UserDataService.GetUserPasswordHash(info.UserName);
var agent = HttpContext.Request.Headers[Microsoft.Net.Http.Headers.HeaderNames.UserAgent];
@@ -53,7 +51,7 @@ namespace SecureCore.Controllers
}
else
{
return Unauthorized();
return Unauthorized(result.Message);
}
}