mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
Hide the password field if it's not needed #1815
This commit is contained in:
parent
e3685e5ea8
commit
62ee9d8cdb
6 changed files with 68 additions and 24 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue