mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-08 18:34:44 +08:00
v1.2版,全面实现SSO登陆
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user