more small tweaks around the username/alias

pull/992/head
Jamie.Rees 8 years ago
parent 9f7523d7c5
commit 3d2209d163

@ -114,9 +114,13 @@ namespace Ombi.Core
}
// could be a local user
var localName = session[SessionKeys.UsernameKey];
var hasSessionKey = session[SessionKeys.UsernameKey] != null;
if (hasSessionKey)
{
return (string)session[SessionKeys.UsernameKey];
}
return localName as string;
return string.Empty;
}

@ -25,6 +25,7 @@
// ************************************************************************/
#endregion
using Newtonsoft.Json;
using Ombi.Helpers;
using Ombi.Helpers.Permissions;
@ -38,5 +39,8 @@ namespace Ombi.Core.Users
public Features Features { get; set; }
public string EmailAddress { get; set; }
public UserType Type { get; set; }
[JsonIgnore]
public string UsernameOrAlias => string.IsNullOrEmpty(UserAlias) ? Username : UserAlias;
}
}

@ -152,10 +152,16 @@ namespace Ombi.Services.Notification
var users = UserHelper.GetUsersWithFeature(Features.RequestAddedNotification).ToList();
Log.Debug("Notifying Users Count {0}", users.Count);
var userNamesWithFeature = users.Select(x => x.Username).ToList();
// Get the usernames or alias depending if they have an alias
var userNamesWithFeature = users.Select(x => x.UsernameOrAlias).ToList();
var usersToNotify = userNamesWithFeature.Intersect(model.AllUsers, StringComparer.CurrentCultureIgnoreCase).ToList();
if (!usersToNotify.Any())
{
Log.Debug("Could not find any users after the .Intersect()");
}
var usersToNotify = userNamesWithFeature.Intersect(model.AllUsers, StringComparer.CurrentCultureIgnoreCase);
Log.Debug("Users being notified for this request count {0}", users.Count);
foreach (var user in usersToNotify)
{

@ -26,6 +26,7 @@
#endregion
using Dapper.Contrib.Extensions;
using Newtonsoft.Json;
namespace Ombi.Store.Models
{

@ -149,9 +149,10 @@ namespace Ombi.UI.Modules
protected bool LoggedIn => Context?.CurrentUser != null;
protected string Culture { get; set; }
private string Culture { get; set; }
protected const string CultureCookieName = "_culture";
protected Response SetCookie()
private Response SetCookie()
{
try
{

@ -564,7 +564,7 @@ namespace Ombi.UI.Modules
UserLogins.Insert(new UserLogins { UserId = userId, Type = UserType.PlexUser, LastLoggedIn = DateTime.UtcNow });
Log.Debug("We are authenticated! Setting session.");
// Add to the session (Used in the BaseModules)
Session[SessionKeys.UsernameKey] = (string)username;
Session[SessionKeys.UsernameKey] = username;
Session[SessionKeys.ClientDateTimeOffsetKey] = dateTimeOffset;
var plexLocal = plexLocalUsers.FirstOrDefault(x => x.Username == username);

Loading…
Cancel
Save