v1.2版,全面实现SSO登陆

This commit is contained in:
yubaolee
2016-07-08 18:51:48 +08:00
parent 032bc20e1e
commit 781ae8900d
19 changed files with 326 additions and 147 deletions

View File

@@ -1,15 +1,24 @@
using System.Web.Mvc;
using OpenAuth.App;
using OpenAuth.App.SSO;
namespace OpenAuth.WebTest.Controllers
{
public class HomeController :Controller
{
[SSOAuth]
public ActionResult Index()
{
var currentUser = AuthUtil.GetCurrentUser();
ViewBag.CurrentUser = currentUser;
return View();
}
public ActionResult Admin()
{
return Redirect("http://localhost:56813?token=" + Request.Cookies["Token"].Value);
}
}
}

View File

@@ -18,7 +18,7 @@ namespace OpenAuth.WebTest.Controllers
[HttpPost]
public ActionResult Index(string username, string password)
{
var token = AuthUtil.Login("670b14728ad9902aecba32e22fa4f6bd", username, "123");
var token = AuthUtil.Login("670b14728ad9902aecba32e22fa4f6bd", username, password);
if (!string.IsNullOrEmpty(token))
return Redirect("/home/index?Token=" + token);
else
@@ -26,5 +26,11 @@ namespace OpenAuth.WebTest.Controllers
return View();
}
}
public ActionResult Logout()
{
AuthUtil.Logout();
return Redirect("/Home/Index");
}
}
}