完成登录处理

This commit is contained in:
yubaolee
2015-12-01 17:30:24 +08:00
parent b1884fd08f
commit 95a10397dc
13 changed files with 174 additions and 34 deletions

View File

@@ -14,6 +14,7 @@
using System.Web.Mvc;
using Infrastructure.Helper;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Mvc.Models;
@@ -29,10 +30,10 @@ namespace OpenAuth.Mvc.Controllers
base.OnActionExecuting(filterContext);
//#region 当Session过期自动跳出登录画面
//if (SessionHelper.GetSessionUser<User>() == null)
//{
// Response.Redirect("/Login/Index");
//}
if (SessionHelper.GetSessionUser<LoginUserVM>() == null)
{
Response.Redirect("/Login/Index");
}
//#endregion
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Infrastructure.Helper;
using OpenAuth.App;
namespace OpenAuth.Mvc.Controllers
@@ -26,7 +27,7 @@ namespace OpenAuth.Mvc.Controllers
{
try
{
_app.Login(username, password);
SessionHelper.AddSessionUser( _app.Login(username, password));
return RedirectToAction("Index", "Home");
}
@@ -35,5 +36,28 @@ namespace OpenAuth.Mvc.Controllers
return View(e.Message);
}
}
/// <summary>
/// 开发者登陆
/// </summary>
public ActionResult LoginByDev()
{
try
{
SessionHelper.AddSessionUser(_app.LoginByDev());
return RedirectToAction("Index", "Home");
}
catch (Exception e)
{
return View(e.Message);
}
}
public ActionResult Logout()
{
SessionHelper.Clear();
return RedirectToAction("Index", "Login");
}
}
}