2016-07-19 15:18:45 +08:00
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Web.Mvc;
|
2016-07-08 11:28:38 +08:00
|
|
|
|
using OpenAuth.App.SSO;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.WebTest.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class LoginController : Controller
|
|
|
|
|
{
|
2016-07-19 15:18:45 +08:00
|
|
|
|
private string _appKey = ConfigurationManager.AppSettings["SSOAppKey"];
|
2016-07-08 11:28:38 +08:00
|
|
|
|
// GET: Login
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
2016-07-19 15:18:45 +08:00
|
|
|
|
ViewBag.AppKey = _appKey;
|
2016-07-08 11:28:38 +08:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult Index(string username, string password)
|
|
|
|
|
{
|
2016-07-19 15:18:45 +08:00
|
|
|
|
var result = AuthUtil.Login(_appKey, username, password);
|
2016-07-11 18:21:26 +08:00
|
|
|
|
if (result.Success)
|
|
|
|
|
return Redirect("/home/index?Token=" + result.Token);
|
2016-07-08 11:28:38 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-07-11 18:21:26 +08:00
|
|
|
|
return View(result);
|
2016-07-08 11:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-08 18:51:48 +08:00
|
|
|
|
|
|
|
|
|
public ActionResult Logout()
|
|
|
|
|
{
|
|
|
|
|
AuthUtil.Logout();
|
|
|
|
|
return Redirect("/Home/Index");
|
|
|
|
|
}
|
2016-07-08 11:28:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|