mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-06-26 05:01:51 +08:00
完成登录处理
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user