2016-10-21 16:35:26 +08:00
|
|
|
|
using Bootstrap.Admin.Models;
|
2016-10-23 15:46:18 +08:00
|
|
|
|
using Bootstrap.DataAccess;
|
2017-01-16 11:42:41 +08:00
|
|
|
|
using Bootstrap.Security;
|
2016-10-23 15:46:18 +08:00
|
|
|
|
using Longbow.Security.Principal;
|
2016-10-21 16:35:26 +08:00
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using System.Web.Security;
|
2016-10-20 17:55:29 +08:00
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin.Controllers
|
|
|
|
|
{
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2016-10-20 17:55:29 +08:00
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2016-10-20 17:55:29 +08:00
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
2016-11-23 18:25:52 +08:00
|
|
|
|
var v = new HeaderBarModel();
|
2016-12-20 13:22:33 +08:00
|
|
|
|
v.HomeUrl = DictHelper.RetrieveHomeUrl();
|
2016-12-22 16:26:42 +08:00
|
|
|
|
if (v.HomeUrl.StartsWith("~/")) return View(v);
|
2016-12-20 13:22:33 +08:00
|
|
|
|
else return Redirect(v.HomeUrl);
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2016-11-06 02:11:03 +08:00
|
|
|
|
/// <returns></returns>
|
2016-11-29 15:07:52 +08:00
|
|
|
|
public ActionResult Lock()
|
2016-11-06 02:11:03 +08:00
|
|
|
|
{
|
2016-11-06 12:28:53 +08:00
|
|
|
|
var user = UserHelper.RetrieveUsersByName(User.Identity.Name);
|
2016-11-29 15:07:52 +08:00
|
|
|
|
var model = new LockModel();
|
2016-11-06 12:28:53 +08:00
|
|
|
|
model.UserName = user.UserName;
|
|
|
|
|
model.DisplayName = user.DisplayName;
|
2016-11-29 15:07:52 +08:00
|
|
|
|
model.ReturnUrl = Url.Encode(Request.UrlReferrer.AbsoluteUri);
|
|
|
|
|
FormsAuthentication.SignOut();
|
2016-11-06 12:28:53 +08:00
|
|
|
|
return View(model);
|
2016-11-06 02:11:03 +08:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2016-10-23 15:46:18 +08:00
|
|
|
|
/// <param name="userName"></param>
|
2016-10-21 16:35:26 +08:00
|
|
|
|
/// <param name="password"></param>
|
|
|
|
|
/// <param name="remember"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[AllowAnonymous]
|
2017-03-26 15:09:05 +08:00
|
|
|
|
public ActionResult Login(LoginModel login)
|
2016-10-20 17:55:29 +08:00
|
|
|
|
{
|
2017-03-26 15:09:05 +08:00
|
|
|
|
FormsAuthentication.SignOut();
|
|
|
|
|
if (!string.IsNullOrEmpty(login.UserName) && (LgbPrincipal.Authenticate(login.UserName, login.Password) || BootstrapUser.Authenticate(login.UserName, login.Password)))
|
2016-10-21 16:35:26 +08:00
|
|
|
|
{
|
2017-03-26 15:09:05 +08:00
|
|
|
|
FormsAuthentication.RedirectFromLoginPage(login.UserName, login.Remember == "true");
|
2016-12-22 16:26:42 +08:00
|
|
|
|
return new EmptyResult();
|
2016-10-21 16:35:26 +08:00
|
|
|
|
}
|
2017-03-26 15:09:05 +08:00
|
|
|
|
return View(login);
|
2016-10-21 16:35:26 +08:00
|
|
|
|
}
|
2016-11-06 16:01:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[AllowAnonymous]
|
2016-11-11 14:32:52 +08:00
|
|
|
|
public ActionResult Register(User p)
|
2016-11-06 16:01:14 +08:00
|
|
|
|
{
|
2016-11-11 14:32:52 +08:00
|
|
|
|
if (string.IsNullOrEmpty(p.UserName) || string.IsNullOrEmpty(p.Password) || string.IsNullOrEmpty(p.DisplayName) || string.IsNullOrEmpty(p.Description)) return View();
|
|
|
|
|
p.UserStatus = 1;
|
|
|
|
|
var result = UserHelper.SaveUser(p);
|
2016-11-10 16:39:07 +08:00
|
|
|
|
if (result)
|
2016-11-10 10:14:27 +08:00
|
|
|
|
{
|
2017-01-15 12:48:29 +08:00
|
|
|
|
return Redirect("~/Content/html/RegResult.html");
|
2016-11-10 10:14:27 +08:00
|
|
|
|
}
|
2016-11-10 16:39:07 +08:00
|
|
|
|
|
|
|
|
|
else
|
2016-11-10 10:14:27 +08:00
|
|
|
|
return View();
|
2016-11-06 16:01:14 +08:00
|
|
|
|
}
|
2016-11-20 20:25:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public ActionResult Mobile()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2016-10-20 17:55:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|