mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Initial Commit
This commit is contained in:
commit
74ac3bb599
106 changed files with 118079 additions and 0 deletions
153
NzbDrone.Web/Controllers/AccountController.cs
Normal file
153
NzbDrone.Web/Controllers/AccountController.cs
Normal file
|
@ -0,0 +1,153 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using NzbDrone.Web.Models;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
|
||||
[HandleError]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
|
||||
public IFormsAuthenticationService FormsService { get; set; }
|
||||
public IMembershipService MembershipService { get; set; }
|
||||
|
||||
protected override void Initialize(RequestContext requestContext)
|
||||
{
|
||||
if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
|
||||
if (MembershipService == null) { MembershipService = new AccountMembershipService(); }
|
||||
|
||||
base.Initialize(requestContext);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/LogOn
|
||||
// **************************************
|
||||
|
||||
public ActionResult LogOn()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult LogOn(LogOnModel model, string returnUrl)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (MembershipService.ValidateUser(model.UserName, model.Password))
|
||||
{
|
||||
FormsService.SignIn(model.UserName, model.RememberMe);
|
||||
if (!String.IsNullOrEmpty(returnUrl))
|
||||
{
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("", "The user name or password provided is incorrect.");
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/LogOff
|
||||
// **************************************
|
||||
|
||||
public ActionResult LogOff()
|
||||
{
|
||||
FormsService.SignOut();
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/Register
|
||||
// **************************************
|
||||
|
||||
public ActionResult Register()
|
||||
{
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Register(RegisterModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// Attempt to register the user
|
||||
MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);
|
||||
|
||||
if (createStatus == MembershipCreateStatus.Success)
|
||||
{
|
||||
FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/ChangePassword
|
||||
// **************************************
|
||||
|
||||
[Authorize]
|
||||
public ActionResult ChangePassword()
|
||||
{
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
public ActionResult ChangePassword(ChangePasswordModel model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))
|
||||
{
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/ChangePasswordSuccess
|
||||
// **************************************
|
||||
|
||||
public ActionResult ChangePasswordSuccess()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
24
NzbDrone.Web/Controllers/HomeController.cs
Normal file
24
NzbDrone.Web/Controllers/HomeController.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
[HandleError]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewData["Message"] = "Welcome to ASP.NET MVC!";
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult About()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
121
NzbDrone.Web/Controllers/SeriesController.cs
Normal file
121
NzbDrone.Web/Controllers/SeriesController.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Controllers;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
public class SeriesController : Controller
|
||||
{
|
||||
private readonly ISeriesController _seriesController;
|
||||
//
|
||||
// GET: /Series/
|
||||
|
||||
public SeriesController(ISeriesController seriesController)
|
||||
{
|
||||
_seriesController = seriesController;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewData.Model = _seriesController.GetSeries().ToList();
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
public ActionResult Sync()
|
||||
{
|
||||
_seriesController.SyncSeriesWithDisk();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GET: /Series/Details/5
|
||||
|
||||
public ActionResult Details(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /Series/Create
|
||||
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//
|
||||
// POST: /Series/Create
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(FormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Add insert logic here
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /Series/Edit/5
|
||||
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//
|
||||
// POST: /Series/Edit/5
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Edit(int id, FormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Add update logic here
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /Series/Delete/5
|
||||
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//
|
||||
// POST: /Series/Delete/5
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Delete(int id, FormCollection collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Add delete logic here
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
20
NzbDrone.Web/Controllers/SettingsController.cs
Normal file
20
NzbDrone.Web/Controllers/SettingsController.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
public class SettingsController : Controller
|
||||
{
|
||||
//
|
||||
// GET: /Settings/
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue