1 check issue #12

2 修改登录为Identity认证方式
This commit is contained in:
yubaolee
2016-04-21 10:54:05 +08:00
parent 9c8b6f8629
commit 2d13810c82
14 changed files with 233 additions and 140 deletions

View File

@@ -24,6 +24,7 @@ using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
using OpenAuth.App;
namespace OpenAuth.Mvc.Controllers
{
@@ -33,8 +34,8 @@ namespace OpenAuth.Mvc.Controllers
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var loginUser = SessionHelper.GetSessionUser<LoginUserVM>();
if (loginUser == null)
var loginUser = AutofacExt.GetFromFac<LoginApp>().GetLoginUser();
if (!User.Identity.IsAuthenticated)
{
filterContext.Result = new RedirectResult("/Login/Index");
return;

View File

@@ -25,7 +25,7 @@ namespace OpenAuth.Mvc.Controllers
[Anonymous]
public ActionResult Index()
{
var user = SessionHelper.GetSessionUser<LoginUserVM>();
var user = AutofacExt.GetFromFac<LoginApp>().GetLoginUser();
return View(user.Modules);
}

View File

@@ -29,7 +29,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
SessionHelper.AddSessionUser( _app.Login(username, password));
_app.Login(username, password);
return RedirectToAction("Index", "Home");
}
@@ -51,19 +51,20 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
SessionHelper.AddSessionUser(_app.LoginByDev());
_app.LoginByDev();
return RedirectToAction("Index", "Home");
}
catch (Exception e)
{
return View(e.Message);
return RedirectToAction("Index", "Login");
}
}
public ActionResult Logout()
{
SessionHelper.Clear();
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Login");
}
}

View File

@@ -45,13 +45,13 @@ namespace OpenAuth.Mvc.Controllers
/// </summary>
public string LoadForTree()
{
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().Modules;
var orgs = AutofacExt.GetFromFac<LoginApp>().GetLoginUser().Modules;
return JsonHelper.Instance.Serialize(orgs);
}
public string LoadModuleWithRoot()
{
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().Modules.MapToList<ModuleView>();
var orgs = AutofacExt.GetFromFac<LoginApp>().GetLoginUser().Modules.MapToList<ModuleView>();
//添加根节点
orgs.Add(new Module
{

View File

@@ -40,7 +40,7 @@ namespace OpenAuth.Mvc.Controllers
/// <returns>System.String.</returns>
public string LoadForTree()
{
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs;
var orgs = AutofacExt.GetFromFac<LoginApp>().GetLoginUser().AccessedOrgs;
return JsonHelper.Instance.Serialize(orgs);
}
/// <summary>
@@ -51,7 +51,7 @@ namespace OpenAuth.Mvc.Controllers
[Anonymous]
public string LoadOrg()
{
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().AccessedOrgs.MapToList<Org>();
var orgs = AutofacExt.GetFromFac<LoginApp>().GetLoginUser().AccessedOrgs.MapToList<Org>();
//添加根节点
orgs.Add(new Org
{

View File

@@ -37,7 +37,7 @@ namespace OpenAuth.Mvc.Controllers
{
var newmodel = new Stock();
model.CopyTo(newmodel);
newmodel.User = SessionHelper.GetSessionUser<LoginUserVM>().User.Account;
newmodel.User = AutofacExt.GetFromFac<LoginApp>().GetLoginUser().User.Account;
_app.AddOrUpdate(newmodel);
}
catch (Exception ex)