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

@@ -19,6 +19,7 @@ using OpenAuth.App;
using System.Reflection;
using System.Web.Mvc;
using OpenAuth.Domain.Interface;
using OpenAuth.Domain.Service;
using OpenAuth.Repository;
namespace OpenAuth.Mvc
@@ -44,6 +45,7 @@ namespace OpenAuth.Mvc
builder.RegisterType<ResourceManagerApp>();
builder.RegisterType<StockManagerApp>();
builder.RegisterType<RevelanceManagerApp>();
builder.RegisterType<AuthoriseService>();
// Register your MVC controllers.
builder.RegisterControllers(typeof(MvcApplication).Assembly);

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)

View File

@@ -296,6 +296,8 @@
<Content Include="Content\jqGrid\i18n\grid.locale-ua.js" />
<Content Include="Content\jqGrid\i18n\grid.locale-vi.js" />
<Content Include="Content\jqGrid\jquery.jqGrid.src.js" />
<Content Include="Content\js\purl.js" />
<Content Include="Content\js\util.js" />
<Content Include="Content\kindeditor_4.1.10\attached\test.txt" />
<Content Include="Content\kindeditor_4.1.10\editor-content.css" />
<Content Include="Content\kindeditor_4.1.10\kindeditor-all-min.js" />

View File

@@ -18,6 +18,8 @@
<!--<add name="OpenAuthDBContext" connectionString="server=127.0.0.1;user id=root;persistsecurityinfo=True;database=openauth;password=123456" providerName="MySql.Data.MySqlClient" />-->
</connectionStrings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<!--定义文件存放位置-->
@@ -58,10 +60,12 @@
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="None" />
<authentication mode="Forms" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<sessionState mode="InProc" timeout="60"/>
<customErrors mode="On" defaultRedirect="/Login/Index">
</customErrors>
</system.web>
<system.webServer>
<modules>