|
|
@ -38,24 +38,31 @@ using Nancy.Validation;
|
|
|
|
using PlexRequests.Api.Interfaces;
|
|
|
|
using PlexRequests.Api.Interfaces;
|
|
|
|
using PlexRequests.Core;
|
|
|
|
using PlexRequests.Core;
|
|
|
|
using PlexRequests.Core.SettingModels;
|
|
|
|
using PlexRequests.Core.SettingModels;
|
|
|
|
|
|
|
|
using PlexRequests.Helpers;
|
|
|
|
|
|
|
|
using PlexRequests.Helpers.Analytics;
|
|
|
|
using PlexRequests.UI.Helpers;
|
|
|
|
using PlexRequests.UI.Helpers;
|
|
|
|
using PlexRequests.UI.Models;
|
|
|
|
using PlexRequests.UI.Models;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using Action = PlexRequests.Helpers.Analytics.Action;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PlexRequests.UI.Modules
|
|
|
|
namespace PlexRequests.UI.Modules
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class UserWizardModule : BaseModule
|
|
|
|
public class UserWizardModule : BaseModule
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public UserWizardModule(ISettingsService<PlexRequestSettings> pr, ISettingsService<PlexSettings> plex, IPlexApi plexApi,
|
|
|
|
public UserWizardModule(ISettingsService<PlexRequestSettings> pr, ISettingsService<PlexSettings> plex, IPlexApi plexApi,
|
|
|
|
ISettingsService<AuthenticationSettings> auth, ICustomUserMapper m) : base("wizard", pr)
|
|
|
|
ISettingsService<AuthenticationSettings> auth, ICustomUserMapper m, IAnalytics a) : base("wizard", pr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PlexSettings = plex;
|
|
|
|
PlexSettings = plex;
|
|
|
|
PlexApi = plexApi;
|
|
|
|
PlexApi = plexApi;
|
|
|
|
PlexRequestSettings = pr;
|
|
|
|
PlexRequestSettings = pr;
|
|
|
|
Auth = auth;
|
|
|
|
Auth = auth;
|
|
|
|
Mapper = m;
|
|
|
|
Mapper = m;
|
|
|
|
|
|
|
|
Analytics = a;
|
|
|
|
|
|
|
|
|
|
|
|
Get["/", true] = async (x, ct) =>
|
|
|
|
Get["/", true] = async (x, ct) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
a.TrackEventAsync(Category.Wizard, Action.Start, "Started the wizard", Username, CookieHelper.GetAnalyticClientId(Cookies));
|
|
|
|
|
|
|
|
|
|
|
|
var settings = await PlexRequestSettings.GetSettingsAsync();
|
|
|
|
var settings = await PlexRequestSettings.GetSettingsAsync();
|
|
|
|
if (settings.Wizard)
|
|
|
|
if (settings.Wizard)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -75,6 +82,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
private ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
|
|
|
|
private ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
|
|
|
|
private ISettingsService<AuthenticationSettings> Auth { get; }
|
|
|
|
private ISettingsService<AuthenticationSettings> Auth { get; }
|
|
|
|
private ICustomUserMapper Mapper { get; }
|
|
|
|
private ICustomUserMapper Mapper { get; }
|
|
|
|
|
|
|
|
private IAnalytics Analytics { get; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Response PlexAuth()
|
|
|
|
private Response PlexAuth()
|
|
|
@ -153,6 +161,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var username = (string)Request.Form.Username;
|
|
|
|
var username = (string)Request.Form.Username;
|
|
|
|
var userId = Mapper.CreateAdmin(username, Request.Form.Password);
|
|
|
|
var userId = Mapper.CreateAdmin(username, Request.Form.Password);
|
|
|
|
|
|
|
|
Analytics.TrackEventAsync(Category.Wizard, Action.Finish, "Finished the wizard", username, CookieHelper.GetAnalyticClientId(Cookies));
|
|
|
|
Session[SessionKeys.UsernameKey] = username;
|
|
|
|
Session[SessionKeys.UsernameKey] = username;
|
|
|
|
|
|
|
|
|
|
|
|
// Destroy the Plex Auth Token
|
|
|
|
// Destroy the Plex Auth Token
|
|
|
@ -163,6 +172,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
settings.Wizard = true;
|
|
|
|
settings.Wizard = true;
|
|
|
|
await PlexRequestSettings.SaveSettingsAsync(settings);
|
|
|
|
await PlexRequestSettings.SaveSettingsAsync(settings);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.LoginAndRedirect((Guid)userId, fallbackRedirectUrl: "/search");
|
|
|
|
return this.LoginAndRedirect((Guid)userId, fallbackRedirectUrl: "/search");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|