mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 18:02:44 +01:00
New: Require password confirmation when setting or changing password
(cherry picked from commit b248163df598dc611ee919d525eb7357256d73d5)
This commit is contained in:
parent
c687b552f0
commit
10f5f3c5c8
@ -34,7 +34,8 @@ function AuthenticationRequiredModalContent(props) {
|
||||
authenticationMethod,
|
||||
authenticationRequired,
|
||||
username,
|
||||
password
|
||||
password,
|
||||
passwordConfirmation
|
||||
} = settings;
|
||||
|
||||
const authenticationEnabled = authenticationMethod && authenticationMethod.value !== 'none';
|
||||
@ -120,6 +121,18 @@ function AuthenticationRequiredModalContent(props) {
|
||||
{...password}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('PasswordConfirmation')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.PASSWORD}
|
||||
name="passwordConfirmation"
|
||||
onChange={onInputChange}
|
||||
helpTextWarning={passwordConfirmation?.value ? undefined : translate('AuthenticationRequiredPasswordConfirmationHelpTextWarning')}
|
||||
{...passwordConfirmation}
|
||||
/>
|
||||
</FormGroup>
|
||||
</div> :
|
||||
null
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ class SecuritySettings extends Component {
|
||||
authenticationRequired,
|
||||
username,
|
||||
password,
|
||||
passwordConfirmation,
|
||||
apiKey,
|
||||
certificateValidation
|
||||
} = settings;
|
||||
@ -193,6 +194,21 @@ class SecuritySettings extends Component {
|
||||
null
|
||||
}
|
||||
|
||||
{
|
||||
authenticationEnabled ?
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('PasswordConfirmation')}</FormLabel>
|
||||
|
||||
<FormInputGroup
|
||||
type={inputTypes.PASSWORD}
|
||||
name="passwordConfirmation"
|
||||
onChange={onInputChange}
|
||||
{...passwordConfirmation}
|
||||
/>
|
||||
</FormGroup> :
|
||||
null
|
||||
}
|
||||
|
||||
<FormGroup>
|
||||
<FormLabel>{translate('ApiKey')}</FormLabel>
|
||||
|
||||
|
@ -86,6 +86,7 @@
|
||||
"AuthenticationRequired": "Authentication Required",
|
||||
"AuthenticationRequiredHelpText": "Change which requests authentication is required for. Do not change unless you understand the risks.",
|
||||
"AuthenticationRequiredPasswordHelpTextWarning": "Enter a new password",
|
||||
"AuthenticationRequiredPasswordConfirmationHelpTextWarning": "Confirm new password",
|
||||
"AuthenticationRequiredUsernameHelpTextWarning": "Enter a new username",
|
||||
"AuthenticationRequiredWarning": "To prevent remote access without authentication, {appName} now requires authentication to be enabled. You can optionally disable authentication from local addresses.",
|
||||
"Auto": "Auto",
|
||||
@ -824,6 +825,7 @@
|
||||
"ParseModalHelpTextDetails": "{appName} will attempt to parse the title and show you details about it",
|
||||
"ParseModalUnableToParse": "Unable to parse the provided title, please try again.",
|
||||
"Password": "Password",
|
||||
"PasswordConfirmation": "Password Confirmation",
|
||||
"Path": "Path",
|
||||
"Paused": "Paused",
|
||||
"Peers": "Peers",
|
||||
|
@ -1,4 +1,4 @@
|
||||
using FluentValidation.Validators;
|
||||
using FluentValidation.Validators;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
||||
namespace NzbDrone.Core.Validation.Paths
|
||||
|
@ -47,6 +47,9 @@ public HostConfigController(IConfigFileProvider configFileProvider,
|
||||
SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationMethod == AuthenticationType.Basic ||
|
||||
c.AuthenticationMethod == AuthenticationType.Forms);
|
||||
|
||||
SharedValidator.RuleFor(c => c.PasswordConfirmation)
|
||||
.Must((resource, p) => IsMatchingPassword(resource)).WithMessage("Must match Password");
|
||||
|
||||
SharedValidator.RuleFor(c => c.SslPort).ValidPort().When(c => c.EnableSsl);
|
||||
SharedValidator.RuleFor(c => c.SslPort).NotEqual(c => c.Port).When(c => c.EnableSsl);
|
||||
|
||||
@ -81,6 +84,23 @@ private bool IsValidSslCertificate(HostConfigResource resource)
|
||||
return cert != null;
|
||||
}
|
||||
|
||||
private bool IsMatchingPassword(HostConfigResource resource)
|
||||
{
|
||||
var user = _userService.FindUser();
|
||||
|
||||
if (user != null && user.Password == resource.Password)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (resource.Password == resource.PasswordConfirmation)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override HostConfigResource GetResourceById(int id)
|
||||
{
|
||||
return GetHostConfig();
|
||||
@ -93,11 +113,10 @@ public HostConfigResource GetHostConfig()
|
||||
resource.Id = 1;
|
||||
|
||||
var user = _userService.FindUser();
|
||||
if (user != null)
|
||||
{
|
||||
resource.Username = user.Username;
|
||||
resource.Password = user.Password;
|
||||
}
|
||||
|
||||
resource.Username = user?.Username ?? string.Empty;
|
||||
resource.Password = user?.Password ?? string.Empty;
|
||||
resource.PasswordConfirmation = string.Empty;
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class HostConfigResource : RestResource
|
||||
public bool AnalyticsEnabled { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string PasswordConfirmation { get; set; }
|
||||
public string LogLevel { get; set; }
|
||||
public string ConsoleLogLevel { get; set; }
|
||||
public string Branch { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user