mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-07 05:31:13 -07:00
more work
This commit is contained in:
parent
81c492aa14
commit
6054f0d436
15 changed files with 192 additions and 23 deletions
|
@ -1,10 +1,17 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Dynamic;
|
||||
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.ModelBinding;
|
||||
using Nancy.Security;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using RequestPlex.Api;
|
||||
using RequestPlex.Core;
|
||||
using RequestPlex.UI.Models;
|
||||
|
||||
namespace RequestPlex.UI.Modules
|
||||
{
|
||||
|
@ -12,12 +19,14 @@ namespace RequestPlex.UI.Modules
|
|||
{
|
||||
public AdminModule()
|
||||
{
|
||||
#if !DEBUG
|
||||
this.RequiresAuthentication();
|
||||
#endif
|
||||
Get["admin/"] = _ =>
|
||||
{
|
||||
dynamic model = new ExpandoObject();
|
||||
model.Errored = Request.Query.error.HasValue;
|
||||
|
||||
model.Port = null;
|
||||
var s = new SettingsService();
|
||||
var settings = s.GetSettings();
|
||||
if (settings != null)
|
||||
|
@ -42,6 +51,22 @@ namespace RequestPlex.UI.Modules
|
|||
s.SaveSettings(port);
|
||||
|
||||
|
||||
return Context.GetRedirect("~/admin");
|
||||
};
|
||||
|
||||
Post["admin/requestauth"] = _ =>
|
||||
{
|
||||
var user = this.Bind<PlexAuth>();
|
||||
|
||||
if (string.IsNullOrEmpty(user.username) || string.IsNullOrEmpty(user.password))
|
||||
{
|
||||
return Context.GetRedirect("~/admin?error=true");
|
||||
}
|
||||
|
||||
var plex = new PlexApi();
|
||||
plex.GetToken(user.username, user.password);
|
||||
|
||||
|
||||
return Context.GetRedirect("~/admin");
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue