diff --git a/NzbDrone.Api/Authentication/AuthenticationService.cs b/NzbDrone.Api/Authentication/AuthenticationService.cs index 9148165f5..17d7e5022 100644 --- a/NzbDrone.Api/Authentication/AuthenticationService.cs +++ b/NzbDrone.Api/Authentication/AuthenticationService.cs @@ -1,14 +1,12 @@ using Nancy.Authentication.Basic; using Nancy.Security; -using NzbDrone.Common; -using NzbDrone.Common.Model; using NzbDrone.Core.Configuration; namespace NzbDrone.Api.Authentication { public interface IAuthenticationService : IUserValidator { - AuthenticationType AuthenticationType { get; } + bool Enabled { get; } } public class AuthenticationService : IAuthenticationService @@ -22,25 +20,29 @@ namespace NzbDrone.Api.Authentication _configFileProvider = configFileProvider; } - public AuthenticationType AuthenticationType - { - get { return _configFileProvider.AuthenticationType; } - } public IUserIdentity Validate(string username, string password) { - if (AuthenticationType == AuthenticationType.Anonymous) + if (!Enabled) { return AnonymousUser; } - if (_configFileProvider.BasicAuthUsername.Equals(username) && - _configFileProvider.BasicAuthPassword.Equals(password)) + if (_configFileProvider.Username.Equals(username) && + _configFileProvider.Password.Equals(password)) { return new NzbDroneUser { UserName = username }; } return null; } + + public bool Enabled + { + get + { + return _configFileProvider.AuthenticationEnabled; + } + } } } diff --git a/NzbDrone.Api/Authentication/EnableBasicAuthInNancy.cs b/NzbDrone.Api/Authentication/EnableBasicAuthInNancy.cs index d3223c270..48ae43b2a 100644 --- a/NzbDrone.Api/Authentication/EnableBasicAuthInNancy.cs +++ b/NzbDrone.Api/Authentication/EnableBasicAuthInNancy.cs @@ -1,7 +1,6 @@ using Nancy; using Nancy.Authentication.Basic; using Nancy.Bootstrapper; -using NzbDrone.Common.Model; namespace NzbDrone.Api.Authentication { @@ -28,7 +27,7 @@ namespace NzbDrone.Api.Authentication private Response RequiresAuthentication(NancyContext context) { Response response = null; - if (context.CurrentUser == null && _authenticationService.AuthenticationType != AuthenticationType.Anonymous) + if (context.CurrentUser == null && _authenticationService.Enabled) { response = new Response { StatusCode = HttpStatusCode.Unauthorized }; } diff --git a/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/NzbDrone.Common.Test/ConfigFileProviderTest.cs index 9ee37246f..bd88a98b7 100644 --- a/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -128,19 +128,9 @@ namespace NzbDrone.Common.Test [Test] public void GetAuthenticationType_No_Existing_Value() { - var result = Subject.AuthenticationType; + var result = Subject.AuthenticationEnabled; - result.Should().Be(AuthenticationType.Anonymous); - } - - [Test] - public void GetAuthenticationType_Basic() - { - Subject.SetValue("AuthenticationType", AuthenticationType.Basic); - - var result = Subject.AuthenticationType; - - result.Should().Be(AuthenticationType.Basic); + result.Should().Be(false); } [Test] diff --git a/NzbDrone.Common/Model/AuthenticationType.cs b/NzbDrone.Common/Model/AuthenticationType.cs deleted file mode 100644 index 31529b179..000000000 --- a/NzbDrone.Common/Model/AuthenticationType.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Linq; - -namespace NzbDrone.Common.Model -{ - public enum AuthenticationType - { - Anonymous, - Basic - } -} diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index 8c2b2a689..5eb5847ed 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -149,7 +149,6 @@ - diff --git a/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 646f0ab62..d93decf86 100644 --- a/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -1,13 +1,11 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Xml.Linq; using NzbDrone.Common; using NzbDrone.Common.Cache; using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Common.Model; namespace NzbDrone.Core.Configuration { @@ -16,11 +14,11 @@ namespace NzbDrone.Core.Configuration Dictionary GetConfigDictionary(); void SaveConfigDictionary(Dictionary configValues); - int Port { get; set; } - bool LaunchBrowser { get; set; } - AuthenticationType AuthenticationType { get; set; } - string BasicAuthUsername { get; set; } - string BasicAuthPassword { get; set; } + int Port { get; } + bool LaunchBrowser { get; } + bool AuthenticationEnabled { get; } + string Username { get; } + string Password { get; } } public class ConfigFileProvider : IConfigFileProvider @@ -80,31 +78,26 @@ namespace NzbDrone.Core.Configuration public int Port { get { return GetValueInt("Port", 8989); } - set { SetValue("Port", value); } } public bool LaunchBrowser { get { return GetValueBoolean("LaunchBrowser", true); } - set { SetValue("LaunchBrowser", value); } } - public AuthenticationType AuthenticationType + public bool AuthenticationEnabled { - get { return GetValueEnum("AuthenticationType", AuthenticationType.Anonymous); } - set { SetValue("AuthenticationType", value); } + get { return GetValueBoolean("AuthenticationEnabled", false); } } - public string BasicAuthUsername + public string Username { - get { return GetValue("BasicAuthUsername", ""); } - set { SetValue("BasicAuthUsername", value); } + get { return GetValue("Username", ""); } } - public string BasicAuthPassword + public string Password { - get { return GetValue("BasicAuthPassword", ""); } - set { SetValue("BasicAuthPassword", value); } + get { return GetValue("Password", ""); } } public int GetValueInt(string key, int defaultValue) diff --git a/UI/Content/Overrides/bootstrap.less b/UI/Content/Overrides/bootstrap.less index 505f87581..707cbf5e4 100644 --- a/UI/Content/Overrides/bootstrap.less +++ b/UI/Content/Overrides/bootstrap.less @@ -15,14 +15,16 @@ } .btn { - min-width : 80px; - &.btn-mini{ - min-width: 0px; + text-transform : capitalize; + min-width : 80px; + + &.btn-mini { + min-width : 0px; } - &.btn-icon-only{ - min-width: 15px; + &.btn-icon-only { + min-width : 15px; } } diff --git a/UI/Settings/General/GeneralTemplate.html b/UI/Settings/General/GeneralTemplate.html index e5d20a166..2650cca79 100644 --- a/UI/Settings/General/GeneralTemplate.html +++ b/UI/Settings/General/GeneralTemplate.html @@ -6,7 +6,7 @@
- + @@ -38,33 +38,36 @@
Security - -
-
- -
-
-
- +
diff --git a/UI/Settings/General/GeneralView.js b/UI/Settings/General/GeneralView.js index 4088bc13e..56900fb50 100644 --- a/UI/Settings/General/GeneralView.js +++ b/UI/Settings/General/GeneralView.js @@ -1,10 +1,43 @@ 'use strict'; -define(['marionette', 'Mixins/AsModelBoundView'], function (Marionette, AsModelBoundView) { - var view = Marionette.ItemView.extend({ - template: 'Settings/General/GeneralTemplate' - } - ); - - return AsModelBoundView.call(view); -}); +define( + [ + 'marionette', + 'Mixins/AsModelBoundView' + ], function (Marionette, AsModelBoundView) { + var view = Marionette.ItemView.extend({ + template: 'Settings/General/GeneralTemplate', + + events: { + 'change .x-auth': '_setAuthOptionsVisibility' + }, + + ui: { + authToggle : '.x-auth', + authOptions: '.x-auth-options' + }, + + + onRender: function(){ + if(!this.ui.authToggle.prop('checked')){ + this.ui.authOptions.hide(); + } + }, + + _setAuthOptionsVisibility: function () { + + var showAuthOptions = this.ui.authToggle.prop('checked'); + + if (showAuthOptions) { + this.ui.authOptions.slideDown(); + } + + else { + this.ui.authOptions.slideUp(); + } + } + + }); + + return AsModelBoundView.call(view); + }); diff --git a/UI/Settings/MediaManagement/Naming/View.js b/UI/Settings/MediaManagement/Naming/View.js index 0a7ee87af..96c5fee14 100644 --- a/UI/Settings/MediaManagement/Naming/View.js +++ b/UI/Settings/MediaManagement/Naming/View.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict'; define( [ 'marionette', @@ -9,32 +9,28 @@ define( template: 'Settings/MediaManagement/Naming/ViewTemplate', ui: { - namingOptions : '.x-naming-options', - renameEpisodesCheckbox : '.x-rename-episodes' + namingOptions : '.x-naming-options', + renameEpisodesCheckbox: '.x-rename-episodes' }, events: { - 'change .x-rename-episodes': '_toggleNamingOptions' + 'change .x-rename-episodes': '_setNamingOptionsVisibility' }, - onShow: function () { - var renameEpisodes = this.model.get('renameEpisodes'); - this._setNamingOptionsVisibility(renameEpisodes); + onRender: function(){ + if(!this.model.get('renameEpisodes')){ + this.ui.namingOptions.hide(); + } }, - _toggleNamingOptions: function() { + _setNamingOptionsVisibility: function () { var checked = this.ui.renameEpisodesCheckbox.prop('checked'); - this._setNamingOptionsVisibility(checked); - }, - - _setNamingOptionsVisibility: function (showNamingOptions) { - - if (showNamingOptions) { - this.ui.namingOptions.show(); + if (checked) { + this.ui.namingOptions.slideDown(); } else { - this.ui.namingOptions.hide(); + this.ui.namingOptions.slideUp(); } } }); diff --git a/UI/Settings/Quality/QualityLayoutTemplate.html b/UI/Settings/Quality/QualityLayoutTemplate.html index d37e62b1d..b1f7ec6d5 100644 --- a/UI/Settings/Quality/QualityLayoutTemplate.html +++ b/UI/Settings/Quality/QualityLayoutTemplate.html @@ -1,6 +1,6 @@ 
-
+