mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-07 21:51:13 -07:00
Added the denied user check to the UserLoginModule. added a test case to cover it.
This commit is contained in:
parent
3eaf1971ec
commit
2ee94f78b4
6 changed files with 59 additions and 23 deletions
|
@ -63,6 +63,12 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
var settings = AuthService.GetSettings();
|
||||
var username = Request.Form.username.Value;
|
||||
|
||||
if (IsUserInDeniedList(username, settings))
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Incorrect User or Password" });
|
||||
}
|
||||
|
||||
var password = string.Empty;
|
||||
if (settings.UsePassword)
|
||||
{
|
||||
|
@ -87,9 +93,11 @@ namespace PlexRequests.UI.Modules
|
|||
authenticated = true;
|
||||
}
|
||||
|
||||
|
||||
// Add to the session (Used in the BaseModules)
|
||||
Session[SessionKeys.UsernameKey] = (string)username;
|
||||
if (authenticated)
|
||||
{
|
||||
// Add to the session (Used in the BaseModules)
|
||||
Session[SessionKeys.UsernameKey] = (string)username;
|
||||
}
|
||||
|
||||
return Response.AsJson(authenticated
|
||||
? new JsonResponseModel { Result = true }
|
||||
|
@ -101,5 +109,10 @@ namespace PlexRequests.UI.Modules
|
|||
var users = Api.GetUsers(authToken);
|
||||
return users.User.Any(x => x.Username == username);
|
||||
}
|
||||
|
||||
private bool IsUserInDeniedList(string username, AuthenticationSettings settings)
|
||||
{
|
||||
return settings.DeniedUserList.Any(x => x.Equals(username));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue