mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Moved source code under src folder - massive change
This commit is contained in:
parent
2fc8123d6b
commit
5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions
|
@ -1,58 +0,0 @@
|
|||
using System;
|
||||
using Nancy;
|
||||
using Nancy.Authentication.Basic;
|
||||
using Nancy.Security;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Api.Authentication
|
||||
{
|
||||
public interface IAuthenticationService : IUserValidator
|
||||
{
|
||||
bool Enabled { get; }
|
||||
bool IsAuthenticated(NancyContext context);
|
||||
}
|
||||
|
||||
public class AuthenticationService : IAuthenticationService
|
||||
{
|
||||
private readonly IConfigFileProvider _configFileProvider;
|
||||
private static readonly NzbDroneUser AnonymousUser = new NzbDroneUser { UserName = "Anonymous" };
|
||||
|
||||
|
||||
public AuthenticationService(IConfigFileProvider configFileProvider)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
}
|
||||
|
||||
|
||||
public IUserIdentity Validate(string username, string password)
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
return AnonymousUser;
|
||||
}
|
||||
|
||||
if (_configFileProvider.Username.Equals(username) &&
|
||||
_configFileProvider.Password.Equals(password))
|
||||
{
|
||||
return new NzbDroneUser { UserName = username };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _configFileProvider.AuthenticationEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAuthenticated(NancyContext context)
|
||||
{
|
||||
if (context.CurrentUser == null && _configFileProvider.AuthenticationEnabled) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue