增加LoginController验证登陆Cookie值

This commit is contained in:
Argo-Lenovo 2016-11-26 13:54:25 +08:00
parent 773270948b
commit 45b0818357
3 changed files with 31 additions and 2 deletions

View File

@ -249,6 +249,7 @@
<Compile Include="Controllers\GroupsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\InfosController.cs" />
<Compile Include="Controllers\LoginController.cs" />
<Compile Include="Controllers\LogsController.cs" />
<Compile Include="Controllers\MenusController.cs" />
<Compile Include="Controllers\MessagesController.cs" />

View File

@ -53,7 +53,6 @@ namespace Bootstrap.Admin.Controllers
model.UserName = userName;
if (LgbPrincipal.IsAdmin(userName) || UserHelper.Authenticate(userName, password))
{
LgbPrincipal.SavePrincipalCookie(new LgbUser() { RealUserName = userName });
FormsAuthentication.RedirectFromLoginPage(userName, false);
}
return View(model);
@ -66,7 +65,6 @@ namespace Bootstrap.Admin.Controllers
public ActionResult Logout()
{
FormsAuthentication.SignOut();
LgbPrincipal.UndoImpersonate();
return RedirectToAction("Login");
}
/// <summary>

View File

@ -0,0 +1,30 @@
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
/// <summary>
///
/// </summary>
public class LoginController : ApiController
{
[HttpGet]
public LoginInfo Get()
{
return new LoginInfo() { UserName = User.Identity.Name, Token = string.Empty };
}
/// <summary>
///
/// </summary>
public class LoginInfo
{
/// <summary>
///
/// </summary>
public string UserName { get; set; }
/// <summary>
///
/// </summary>
public string Token { get; set; }
}
}
}