fixed authentication.

pull/4/head
kay.one 12 years ago
parent 028bd5251c
commit 3bed87ec4e

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nancy.Authentication.Basic;
using Nancy.Authentication.Basic;
using Nancy.Security;
using NzbDrone.Common;
using NzbDrone.Common.Model;
namespace NzbDrone.Api.Authentication
{
@ -19,10 +16,15 @@ namespace NzbDrone.Api.Authentication
public IUserIdentity Validate(string username, string password)
{
if (_configFileProvider.AuthenticationType == AuthenticationType.Anonymous)
{
return new NzbDroneUser { UserName = "Anonymous" };
}
if (_configFileProvider.BasicAuthUsername.Equals(username) &&
_configFileProvider.BasicAuthPassword.Equals(password))
{
return new NzbDroneUser { UserName = username};
return new NzbDroneUser { UserName = username };
}
return null;

@ -39,12 +39,9 @@ namespace NzbDrone.Api
container.Resolve<IMessageAggregator>().PublishEvent(new ApplicationStartedEvent());
if (container.Resolve<IConfigFileProvider>().AuthenticationType == AuthenticationType.Basic)
{
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"NzbDrone"));
}
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(
container.Resolve<IUserValidator>(),
"NzbDrone"));
ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve<NzbDroneErrorPipeline>().HandleException);
}

Loading…
Cancel
Save