New: Add ValueHash for hidden API keys via the API
This commit is contained in:
parent
dee8820b1f
commit
d86d78954e
|
@ -13,6 +13,7 @@ namespace Sonarr.Http.ClientSchema
|
||||||
public string HelpTextWarning { get; set; }
|
public string HelpTextWarning { get; set; }
|
||||||
public string HelpLink { get; set; }
|
public string HelpLink { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
|
public string ValueHash { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public bool Advanced { get; set; }
|
public bool Advanced { get; set; }
|
||||||
public List<SelectOption> SelectOptions { get; set; }
|
public List<SelectOption> SelectOptions { get; set; }
|
||||||
|
|
|
@ -7,6 +7,7 @@ using NzbDrone.Common.EnsureThat;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Reflection;
|
using NzbDrone.Common.Reflection;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
|
|
||||||
namespace Sonarr.Http.ClientSchema
|
namespace Sonarr.Http.ClientSchema
|
||||||
|
@ -30,8 +31,13 @@ namespace Sonarr.Http.ClientSchema
|
||||||
field.Value = mapping.GetterFunc(model);
|
field.Value = mapping.GetterFunc(model);
|
||||||
|
|
||||||
if (field.Value != null && !field.Value.Equals(string.Empty) &&
|
if (field.Value != null && !field.Value.Equals(string.Empty) &&
|
||||||
(field.Privacy == PrivacyLevel.ApiKey || field.Privacy == PrivacyLevel.Password))
|
field.Privacy is PrivacyLevel.ApiKey or PrivacyLevel.Password)
|
||||||
{
|
{
|
||||||
|
if (field.Privacy == PrivacyLevel.ApiKey)
|
||||||
|
{
|
||||||
|
field.ValueHash = field.Value.ToString()?.SHA256Hash()?.AsSpan(0, 6).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
field.Value = PRIVATE_VALUE;
|
field.Value = PRIVATE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue