Hide the password field if it's not needed #1815

This commit is contained in:
Jamie 2018-01-18 08:23:45 +00:00
commit 62ee9d8cdb
6 changed files with 68 additions and 24 deletions

View file

@ -64,19 +64,11 @@ namespace Ombi.Core.Authentication
public override async Task<bool> CheckPasswordAsync(OmbiUser user, string password)
{
var authSettings = await _authSettings.GetSettingsAsync();
if (authSettings.AllowNoPassword)
var requiresPassword = await RequiresPassword(user);
if (!requiresPassword)
{
// Check their roles
var roles = await GetRolesAsync(user);
if (roles.Contains(OmbiRoles.Admin) || roles.Contains(OmbiRoles.PowerUser))
{
// Do nothing, let it continue to check the password
}
else
{
return true;
}
// Let them through!
return true;
}
if (user.UserType == UserType.LocalUser)
{
@ -93,6 +85,22 @@ namespace Ombi.Core.Authentication
return false;
}
public async Task<bool> RequiresPassword(OmbiUser user)
{
var authSettings = await _authSettings.GetSettingsAsync();
if (authSettings.AllowNoPassword)
{
var roles = await GetRolesAsync(user);
if (roles.Contains(OmbiRoles.Admin) || roles.Contains(OmbiRoles.PowerUser))
{
// We require a password
return true;
}
return false;
}
return true;
}
/// <summary>
/// Sign the user into plex and make sure we can get the authentication token.
/// <remarks>We do not check if the user is in the owners "friends" since they must have a local user account to get this far</remarks>