mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
Merge pull request #1295 from tidusjar/dev
Some bug fixes around user management and small tweaks in the newsletter
This commit is contained in:
commit
8937457890
11 changed files with 76 additions and 66 deletions
|
@ -63,7 +63,9 @@ namespace Ombi.Core.Users
|
||||||
Username = localUsers.UserName,
|
Username = localUsers.UserName,
|
||||||
UserAlias = props.UserAlias,
|
UserAlias = props.UserAlias,
|
||||||
EmailAddress = props.EmailAddress,
|
EmailAddress = props.EmailAddress,
|
||||||
Permissions = (Permissions) localUsers.Permissions
|
Permissions = (Permissions) localUsers.Permissions,
|
||||||
|
UserId = localUsers.UserGuid,
|
||||||
|
Features = (Features)localUsers.Features
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +78,10 @@ namespace Ombi.Core.Users
|
||||||
Username = plexUsers.Username,
|
Username = plexUsers.Username,
|
||||||
UserAlias = plexUsers.UserAlias,
|
UserAlias = plexUsers.UserAlias,
|
||||||
EmailAddress = plexUsers.EmailAddress,
|
EmailAddress = plexUsers.EmailAddress,
|
||||||
Permissions = (Permissions)plexUsers.Permissions
|
Permissions = (Permissions)plexUsers.Permissions,
|
||||||
|
UserId = plexUsers.PlexUserId,
|
||||||
|
|
||||||
|
Features = (Features)plexUsers.Features
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +94,9 @@ namespace Ombi.Core.Users
|
||||||
Username = embyUsers.Username,
|
Username = embyUsers.Username,
|
||||||
UserAlias = embyUsers.UserAlias,
|
UserAlias = embyUsers.UserAlias,
|
||||||
EmailAddress = embyUsers.EmailAddress,
|
EmailAddress = embyUsers.EmailAddress,
|
||||||
Permissions = (Permissions)embyUsers.Permissions
|
Permissions = (Permissions)embyUsers.Permissions,
|
||||||
|
UserId = embyUsers.EmbyUserId,
|
||||||
|
Features = (Features)embyUsers.Features
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Ombi.Core.Users
|
||||||
public Features Features { get; set; }
|
public Features Features { get; set; }
|
||||||
public string EmailAddress { get; set; }
|
public string EmailAddress { get; set; }
|
||||||
public UserType Type { get; set; }
|
public UserType Type { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string UsernameOrAlias => string.IsNullOrEmpty(UserAlias) ? Username : UserAlias;
|
public string UsernameOrAlias => string.IsNullOrEmpty(UserAlias) ? Username : UserAlias;
|
||||||
|
|
|
@ -39,6 +39,7 @@ namespace Ombi.Services.Interfaces
|
||||||
/// <param name="model">The model.</param>
|
/// <param name="model">The model.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task Publish(NotificationModel model);
|
Task Publish(NotificationModel model);
|
||||||
|
Task PublishTest(NotificationModel model, Settings settings, INotification type);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a notification to the user, this is usually for testing the settings.
|
/// Sends a notification to the user, this is usually for testing the settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -49,7 +49,7 @@ using PlexMediaType = Ombi.Store.Models.Plex.PlexMediaType;
|
||||||
|
|
||||||
namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
{
|
{
|
||||||
public class
|
public class
|
||||||
PlexRecentlyAddedNewsletter : HtmlTemplateGenerator, IPlexNewsletter
|
PlexRecentlyAddedNewsletter : HtmlTemplateGenerator, IPlexNewsletter
|
||||||
{
|
{
|
||||||
public PlexRecentlyAddedNewsletter(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
public PlexRecentlyAddedNewsletter(IPlexApi api, ISettingsService<PlexSettings> plexSettings,
|
||||||
|
@ -168,7 +168,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
recentlyAddedModel.Add(new PlexRecentlyAddedModel
|
recentlyAddedModel.Add(new PlexRecentlyAddedModel
|
||||||
{
|
{
|
||||||
Metadata = i,
|
Metadata = i,
|
||||||
EpisodeMetadata = new List<PlexEpisodeMetadata>() {episodeInfo},
|
EpisodeMetadata = new List<PlexEpisodeMetadata>() { episodeInfo },
|
||||||
Content = relatedSeries
|
Content = relatedSeries
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -186,33 +186,12 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
//var ep = filteredEp.Where(x => x.ShowTitle == t.Title);
|
|
||||||
|
|
||||||
if (filteredEp.Any())
|
info.Add(new PlexRecentlyAddedModel
|
||||||
{
|
{
|
||||||
var episodeList = new List<PlexEpisodeMetadata>();
|
Metadata = i,
|
||||||
foreach (var ep in filteredEp)
|
Content = t
|
||||||
{
|
});
|
||||||
var epInfo = Api.GetEpisodeMetaData(plexSettings.PlexAuthToken, plexSettings.FullUri,
|
|
||||||
ep.RatingKey);
|
|
||||||
episodeList.Add(epInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
info.Add(new PlexRecentlyAddedModel
|
|
||||||
{
|
|
||||||
Metadata = i,
|
|
||||||
Content = t,
|
|
||||||
EpisodeMetadata = episodeList
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info.Add(new PlexRecentlyAddedModel
|
|
||||||
{
|
|
||||||
Metadata = i,
|
|
||||||
Content = t
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GenerateTvHtml(info, sb);
|
GenerateTvHtml(info, sb);
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
if (embySettings.Enable)
|
if (embySettings.Enable)
|
||||||
{
|
{
|
||||||
var letter = EmbyNewsletter.GetNewsletter(testEmail) ?? new Newsletter();
|
var letter = EmbyNewsletter.GetNewsletter(testEmail) ?? new Newsletter();
|
||||||
if (letter.Send)
|
if (letter.Send || testEmail)
|
||||||
{
|
{
|
||||||
SendNewsletter(newletterSettings, letter.Html, testEmail, "New Content On Emby!");
|
SendNewsletter(newletterSettings, letter.Html, testEmail, "New Content On Emby!");
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
|
||||||
if (plexSettings.Enable)
|
if (plexSettings.Enable)
|
||||||
{
|
{
|
||||||
var letter = PlexNewsletter.GetNewsletter(testEmail) ?? new Newsletter();
|
var letter = PlexNewsletter.GetNewsletter(testEmail) ?? new Newsletter();
|
||||||
if (letter.Send)
|
if (letter.Send || testEmail)
|
||||||
{
|
{
|
||||||
SendNewsletter(newletterSettings, letter.Html, testEmail);
|
SendNewsletter(newletterSettings, letter.Html, testEmail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,7 @@ namespace Ombi.Services.Notification
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Error(e);
|
Log.Error(e);
|
||||||
|
throw new InvalidOperationException(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,13 @@ namespace Ombi.Services.Notification
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error(ex, $"Notification '{notification.NotificationName}' failed with exception");
|
Log.Error(ex, $"Notification '{notification.NotificationName}' failed with exception");
|
||||||
|
throw new InvalidOperationException(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task PublishTest(NotificationModel model, Settings settings, INotification type)
|
||||||
|
{
|
||||||
|
await type.NotifyAsync(model, settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -76,7 +76,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td ng-hide="hideColumns">
|
<td ng-hide="hideColumns">
|
||||||
<span ng-if="u.type === 1">Local User</span>
|
<span ng-if="u.type === 1">Local User</span>
|
||||||
<span ng-if="u.type === 3">Plex User</span>
|
<span ng-if="u.type === 0">Plex User</span>
|
||||||
<span ng-if="u.type === 2">Emby User</span>
|
<span ng-if="u.type === 2">Emby User</span>
|
||||||
</td>
|
</td>
|
||||||
<td ng-hide="hideColumns" ng-bind="u.lastLoggedIn === minDate ? 'Never' : formatDate(u.lastLoggedIn)"></td>
|
<td ng-hide="hideColumns" ng-bind="u.lastLoggedIn === minDate ? 'Never' : formatDate(u.lastLoggedIn)"></td>
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
ISlackApi slackApi, ISettingsService<LandingPageSettings> lp,
|
ISlackApi slackApi, ISettingsService<LandingPageSettings> lp,
|
||||||
ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics,
|
ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics,
|
||||||
ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded, IMassEmail massEmail,
|
ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded, IMassEmail massEmail,
|
||||||
ISettingsService<WatcherSettings> watcherSettings ,
|
ISettingsService<WatcherSettings> watcherSettings,
|
||||||
ISettingsService<DiscordNotificationSettings> discord,
|
ISettingsService<DiscordNotificationSettings> discord,
|
||||||
IDiscordApi discordapi, ISettingsService<RadarrSettings> settings, IRadarrApi radarrApi,
|
IDiscordApi discordapi, ISettingsService<RadarrSettings> settings, IRadarrApi radarrApi,
|
||||||
ISettingsService<EmbySettings> embySettings, IEmbyApi emby
|
ISettingsService<EmbySettings> embySettings, IEmbyApi emby
|
||||||
|
@ -168,9 +168,9 @@ namespace Ombi.UI.Modules.Admin
|
||||||
RadarrApi = radarrApi;
|
RadarrApi = radarrApi;
|
||||||
EmbyApi = emby;
|
EmbyApi = emby;
|
||||||
EmbySettings = embySettings;
|
EmbySettings = embySettings;
|
||||||
|
|
||||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||||
|
|
||||||
Get["/"] = _ => Admin();
|
Get["/"] = _ => Admin();
|
||||||
|
|
||||||
Get["/authentication", true] = async (x, ct) => await Authentication();
|
Get["/authentication", true] = async (x, ct) => await Authentication();
|
||||||
|
@ -226,7 +226,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
Get["/newsletter", true] = async (x, ct) => await Newsletter();
|
Get["/newsletter", true] = async (x, ct) => await Newsletter();
|
||||||
Post["/newsletter", true] = async (x, ct) => await SaveNewsletter();
|
Post["/newsletter", true] = async (x, ct) => await SaveNewsletter();
|
||||||
Post["/testnewsletteradminemail"] = x => TestNewsletterAdminEmail();
|
Post["/testnewsletteradminemail"] = x => TestNewsletterAdminEmail();
|
||||||
|
|
||||||
Get["/massemail"] = _ => MassEmailView();
|
Get["/massemail"] = _ => MassEmailView();
|
||||||
Post["/testmassadminemail"] = x => TestMassAdminEmail();
|
Post["/testmassadminemail"] = x => TestMassAdminEmail();
|
||||||
Post["/sendmassemail"] = x => SendMassEmail();
|
Post["/sendmassemail"] = x => SendMassEmail();
|
||||||
|
@ -453,16 +453,16 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
var plexSettings = this.Bind<PlexSettings>();
|
var plexSettings = this.Bind<PlexSettings>();
|
||||||
|
|
||||||
if (plexSettings.Enable)
|
if (plexSettings.Enable)
|
||||||
{
|
{
|
||||||
var valid = this.Validate(plexSettings);
|
var valid = this.Validate(plexSettings);
|
||||||
if (!valid.IsValid)
|
if (!valid.IsValid)
|
||||||
{
|
{
|
||||||
return Response.AsJson(valid.SendJsonError());
|
return Response.AsJson(valid.SendJsonError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (plexSettings.Enable)
|
if (plexSettings.Enable)
|
||||||
{
|
{
|
||||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||||
|
@ -565,9 +565,9 @@ namespace Ombi.UI.Modules.Admin
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Negotiator Sickrage()
|
private Negotiator Sickrage()
|
||||||
{
|
{
|
||||||
|
@ -639,12 +639,14 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
NotificationService.Subscribe(new EmailMessageNotification(EmailService));
|
NotificationService.Subscribe(new EmailMessageNotification(EmailService));
|
||||||
settings.Enabled = true;
|
settings.Enabled = true;
|
||||||
await NotificationService.Publish(notificationModel, settings);
|
await NotificationService.PublishTest(notificationModel, settings, new EmailMessageNotification(EmailService));
|
||||||
Log.Info("Sent email notification test");
|
Log.Info("Sent email notification test");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error("Failed to subscribe and publish test Email Notification");
|
Log.Error("Failed to subscribe and publish test Email Notification");
|
||||||
|
var msg = "Failed: " + ex.Message;
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = msg });
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -653,7 +655,9 @@ namespace Ombi.UI.Modules.Admin
|
||||||
NotificationService.UnSubscribe(new EmailMessageNotification(EmailService));
|
NotificationService.UnSubscribe(new EmailMessageNotification(EmailService));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Email Notification!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Email Notification!" });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response SaveEmailNotifications()
|
private Response SaveEmailNotifications()
|
||||||
|
@ -739,7 +743,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService));
|
NotificationService.Subscribe(new PushbulletNotification(PushbulletApi, PushbulletService));
|
||||||
settings.Enabled = true;
|
settings.Enabled = true;
|
||||||
await NotificationService.Publish(notificationModel, settings);
|
await NotificationService.PublishTest(notificationModel, settings, new PushbulletNotification(PushbulletApi, PushbulletService));
|
||||||
Log.Info("Sent pushbullet notification test");
|
Log.Info("Sent pushbullet notification test");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -805,7 +809,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
NotificationService.Subscribe(new PushoverNotification(PushoverApi, PushoverService));
|
NotificationService.Subscribe(new PushoverNotification(PushoverApi, PushoverService));
|
||||||
settings.Enabled = true;
|
settings.Enabled = true;
|
||||||
await NotificationService.Publish(notificationModel, settings);
|
await NotificationService.PublishTest(notificationModel, settings, new PushoverNotification(PushoverApi, PushoverService));
|
||||||
Log.Info("Sent pushover notification test");
|
Log.Info("Sent pushover notification test");
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -832,7 +836,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
}
|
}
|
||||||
if (!settings.Enabled)
|
if (!settings.Enabled)
|
||||||
{
|
{
|
||||||
return Response.AsJson(new CouchPotatoProfiles{list = new List<ProfileList>()});
|
return Response.AsJson(new CouchPotatoProfiles { list = new List<ProfileList>() });
|
||||||
}
|
}
|
||||||
var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey);
|
var profiles = CpApi.GetProfiles(settings.FullUri, settings.ApiKey);
|
||||||
|
|
||||||
|
@ -1000,7 +1004,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
NotificationService.Subscribe(new SlackNotification(SlackApi, SlackSettings));
|
NotificationService.Subscribe(new SlackNotification(SlackApi, SlackSettings));
|
||||||
settings.Enabled = true;
|
settings.Enabled = true;
|
||||||
await NotificationService.Publish(notificationModel, settings);
|
await NotificationService.PublishTest(notificationModel, settings, new SlackNotification(SlackApi, SlackSettings));
|
||||||
Log.Info("Sent slack notification test");
|
Log.Info("Sent slack notification test");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -1071,7 +1075,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
NotificationService.Subscribe(new DiscordNotification(DiscordApi, DiscordSettings));
|
NotificationService.Subscribe(new DiscordNotification(DiscordApi, DiscordSettings));
|
||||||
settings.Enabled = true;
|
settings.Enabled = true;
|
||||||
await NotificationService.Publish(notificationModel, settings);
|
await NotificationService.PublishTest(notificationModel, settings, new DiscordNotification(DiscordApi, DiscordSettings));
|
||||||
Log.Info("Sent Discord notification test");
|
Log.Info("Sent Discord notification test");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -1210,12 +1214,12 @@ namespace Ombi.UI.Modules.Admin
|
||||||
PlexEpisodeCacher = s.PlexEpisodeCacher,
|
PlexEpisodeCacher = s.PlexEpisodeCacher,
|
||||||
PlexUserChecker = s.PlexUserChecker,
|
PlexUserChecker = s.PlexUserChecker,
|
||||||
UserRequestLimitResetter = s.UserRequestLimitResetter,
|
UserRequestLimitResetter = s.UserRequestLimitResetter,
|
||||||
EmbyAvailabilityChecker = s.EmbyAvailabilityChecker,
|
EmbyAvailabilityChecker = s.EmbyAvailabilityChecker,
|
||||||
EmbyContentCacher = s.EmbyContentCacher,
|
EmbyContentCacher = s.EmbyContentCacher,
|
||||||
EmbyEpisodeCacher = s.EmbyEpisodeCacher,
|
EmbyEpisodeCacher = s.EmbyEpisodeCacher,
|
||||||
EmbyUserChecker = s.EmbyUserChecker,
|
EmbyUserChecker = s.EmbyUserChecker,
|
||||||
RadarrCacher = s.RadarrCacher,
|
RadarrCacher = s.RadarrCacher,
|
||||||
WatcherCacher = s.WatcherCacher
|
WatcherCacher = s.WatcherCacher
|
||||||
};
|
};
|
||||||
return View["SchedulerSettings", model];
|
return View["SchedulerSettings", model];
|
||||||
}
|
}
|
||||||
|
@ -1278,7 +1282,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
var model = this.Bind<NotificationSettingsV2>();
|
var model = this.Bind<NotificationSettingsV2>();
|
||||||
return View["NotificationSettings", model];
|
return View["NotificationSettings", model];
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response TestNewsletterAdminEmail()
|
private Response TestNewsletterAdminEmail()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1299,7 +1303,8 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
var settings = this.Bind<MassEmailSettings>();
|
var settings = this.Bind<MassEmailSettings>();
|
||||||
Log.Debug("Clicked Admin Mass Email Test");
|
Log.Debug("Clicked Admin Mass Email Test");
|
||||||
if (settings.Subject == null) {
|
if (settings.Subject == null)
|
||||||
|
{
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Subject" });
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Please Set a Subject" });
|
||||||
}
|
}
|
||||||
if (settings.Body == null)
|
if (settings.Body == null)
|
||||||
|
|
|
@ -122,8 +122,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
throw e;
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,8 @@ namespace Ombi.UI.Modules
|
||||||
{
|
{
|
||||||
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexSettings> plexSettings, ISettingsService<PlexRequestSettings> pr,
|
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexSettings> plexSettings, ISettingsService<PlexRequestSettings> pr,
|
||||||
ISettingsService<LandingPageSettings> lp, IAnalytics a, IResourceLinker linker, IRepository<UserLogins> userLogins, IExternalUserRepository<PlexUsers> plexUsers, ICustomUserMapper custom,
|
ISettingsService<LandingPageSettings> lp, IAnalytics a, IResourceLinker linker, IRepository<UserLogins> userLogins, IExternalUserRepository<PlexUsers> plexUsers, ICustomUserMapper custom,
|
||||||
ISecurityExtensions security, ISettingsService<UserManagementSettings> userManagementSettings, IEmbyApi embyApi, ISettingsService<EmbySettings> emby, IExternalUserRepository<EmbyUsers> embyU)
|
ISecurityExtensions security, ISettingsService<UserManagementSettings> userManagementSettings, IEmbyApi embyApi, ISettingsService<EmbySettings> emby, IExternalUserRepository<EmbyUsers> embyU,
|
||||||
|
IUserHelper userHelper)
|
||||||
: base("userlogin", pr, security)
|
: base("userlogin", pr, security)
|
||||||
{
|
{
|
||||||
AuthService = auth;
|
AuthService = auth;
|
||||||
|
@ -75,6 +76,7 @@ namespace Ombi.UI.Modules
|
||||||
EmbySettings = emby;
|
EmbySettings = emby;
|
||||||
EmbyApi = embyApi;
|
EmbyApi = embyApi;
|
||||||
EmbyUserRepository = embyU;
|
EmbyUserRepository = embyU;
|
||||||
|
UserHelper = userHelper;
|
||||||
|
|
||||||
Post["/", true] = async (x, ct) => await LoginUser();
|
Post["/", true] = async (x, ct) => await LoginUser();
|
||||||
Get["/logout"] = x => Logout();
|
Get["/logout"] = x => Logout();
|
||||||
|
@ -135,6 +137,7 @@ namespace Ombi.UI.Modules
|
||||||
private IExternalUserRepository<EmbyUsers> EmbyUserRepository { get; }
|
private IExternalUserRepository<EmbyUsers> EmbyUserRepository { get; }
|
||||||
private ICustomUserMapper CustomUserMapper { get; }
|
private ICustomUserMapper CustomUserMapper { get; }
|
||||||
private ISettingsService<UserManagementSettings> UserManagementSettings { get; }
|
private ISettingsService<UserManagementSettings> UserManagementSettings { get; }
|
||||||
|
private IUserHelper UserHelper { get; }
|
||||||
|
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
@ -683,6 +686,14 @@ namespace Ombi.UI.Modules
|
||||||
{
|
{
|
||||||
type = UserType.EmbyUser;;
|
type = UserType.EmbyUser;;
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(userId))
|
||||||
|
{
|
||||||
|
// It's possible we have no auth enabled meaning the userId is empty
|
||||||
|
// Let's find that user!
|
||||||
|
|
||||||
|
var user = UserHelper.GetUser(username);
|
||||||
|
userId = user.UserId;
|
||||||
|
}
|
||||||
UserLogins.Insert(new UserLogins { UserId = userId, Type = type, LastLoggedIn = DateTime.UtcNow });
|
UserLogins.Insert(new UserLogins { UserId = userId, Type = type, LastLoggedIn = DateTime.UtcNow });
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue