mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
增加登陆逻辑,如果开启,只需要去掉basecontroller中的注释就行
This commit is contained in:
@@ -29,9 +29,9 @@ namespace OpenAuth.Mvc.Controllers
|
||||
base.OnActionExecuting(filterContext);
|
||||
|
||||
//#region 当Session过期自动跳出登录画面
|
||||
//if (SessionHelper.GetSessionUser<LoginViewModel>() == null)
|
||||
//if (SessionHelper.GetSessionUser<User>() == null)
|
||||
//{
|
||||
// Response.Redirect("~/Account/Login");
|
||||
// Response.Redirect("/Login/Index");
|
||||
//}
|
||||
//#endregion
|
||||
}
|
||||
|
@@ -26,10 +26,5 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Login()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
39
OpenAuth.Mvc/Controllers/LoginController.cs
Normal file
39
OpenAuth.Mvc/Controllers/LoginController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class LoginController : Controller
|
||||
{
|
||||
private LoginApp _app;
|
||||
|
||||
public LoginController()
|
||||
{
|
||||
_app = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp));
|
||||
}
|
||||
// GET: Login
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Index(string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Login(username, password);
|
||||
return RedirectToAction("Index", "Home");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return View(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user