pull/794/head
tidusjar 8 years ago
parent 33398084be
commit 5c023341b6

@ -1,6 +1,7 @@
using System;
using Nancy;
using Nancy.Security;
using Nancy.Session;
using PlexRequests.Helpers.Permissions;
namespace PlexRequests.Core
@ -29,6 +30,6 @@ namespace PlexRequests.Core
/// </summary>
/// <param name="username">The username.</param>
/// <returns><c>null</c> if we cannot find a user</returns>
string GetUsername(string username);
string GetUsername(string username, ISession session);
}
}

@ -30,6 +30,7 @@ using Nancy;
using Nancy.Linker;
using Nancy.Responses;
using Nancy.Security;
using Nancy.Session;
using PlexRequests.Core.Models;
using PlexRequests.Helpers;
using PlexRequests.Helpers.Permissions;
@ -91,7 +92,7 @@ namespace PlexRequests.Core
/// </summary>
/// <param name="username">The username.</param>
/// <returns><c>null</c> if we cannot find a user</returns>
public string GetUsername(string username)
public string GetUsername(string username, ISession session)
{
var plexUser = PlexUsers.GetUserByUsername(username);
if (plexUser != null)
@ -119,7 +120,11 @@ namespace PlexRequests.Core
return dbUser.UserName;
}
}
return null;
// could be a local user
var localName = session[SessionKeys.UsernameKey];
return localName as string;
}

@ -112,7 +112,7 @@ namespace PlexRequests.UI.Modules
{
try
{
var username = Security.GetUsername(User.UserName);
var username = Security.GetUsername(User.UserName, Session);
if (string.IsNullOrEmpty(username))
{
return Session[SessionKeys.UsernameKey].ToString();

@ -228,6 +228,20 @@ namespace PlexRequests.UI.Modules
loginGuid = Guid.Parse(dbUser.UserGuid);
}
if (loginGuid != Guid.Empty)
{
if (!settings.UserAuthentication)// Do not need to auth make admin use login screen for now TODO remove this
{
var perms = (Permissions)dbUser.Permissions;
if (perms.HasFlag(Permissions.Administrator))
{
var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex");
Session["TempMessage"] = Resources.UI.UserLogin_AdminUsePassword;
return Response.AsRedirect(uri.ToString());
}
}
}
if(loginGuid == Guid.Empty && settings.UserAuthentication)
{
var defaultSettings = UserManagementSettings.GetSettings();

@ -473,4 +473,7 @@
<data name="Layout_Usermanagement" xml:space="preserve">
<value>User Management</value>
</data>
<data name="UserLogin_AdminUsePassword" xml:space="preserve">
<value>If you are an administrator, please use the other login page</value>
</data>
</root>

@ -223,7 +223,7 @@ namespace PlexRequests.UI.Resources {
}
/// <summary>
/// Looks up a localized string similar to A background process is currently running, so there might be some unexpected behavior. This shouldn&apos;t take too long..
/// Looks up a localized string similar to Currently we are indexing all of the available tv shows and movies on the Plex server, so there might be some unexpected behavior. This shouldn&apos;t take too long..
/// </summary>
public static string Layout_CacherRunning {
get {
@ -1113,6 +1113,15 @@ namespace PlexRequests.UI.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to If you are an administrator, please use the other login page.
/// </summary>
public static string UserLogin_AdminUsePassword {
get {
return ResourceManager.GetString("UserLogin_AdminUsePassword", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Incorrect User or Password.
/// </summary>

@ -37,11 +37,6 @@
</li>
}
<li role="presentation" class="nav-tab-right nav-tab-icononly">
<a href="#NotificationsTab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-bell"></i></a>
</li>
</ul>
<!-- Tab panes -->

@ -93,6 +93,17 @@
</li>
}
else if (Html.IsLoggedIn(Context)) // Logged in but not admin
{
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-user"></i> @UI.Layout_Welcome @Context.Request.Session[SessionKeys.UsernameKey] <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="@url/logout"><i class="fa fa-sign-out"></i> @UI.Layout_Logout</a></li>
</ul>
</li>
}
<li class="dropdown">

Loading…
Cancel
Save