OpenAuth.Net/OpenAuth.WebTest/Controllers/LoginController.cs
小色 ffb40b28c1 拿掉地址栏Token,因为特别不安全。
小王,xxx系统的地址是多少。。。然后账号就泄露了

缺点是Token不能跨域。

OpenAuth.WebApi\Web.config
修改一个provider标签MySql.Data.MySqlClient
使用vs自带功能整理了一下格式。
2017-12-24 17:55:02 +08:00

47 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Configuration;
using System.Web.Mvc;
using OpenAuth.App.SSO;
using System.Web;
using System;
namespace OpenAuth.WebTest.Controllers
{
public class LoginController : Controller
{
private string _appKey = ConfigurationManager.AppSettings["SSOAppKey"];
// GET: Login
public ActionResult Index()
{
ViewBag.AppKey = _appKey;
return View();
}
[HttpPost]
public ActionResult Index(string username, string password)
{
var result = AuthUtil.Login(_appKey, username, password);
if (result.Code == 200)
{
var cookie = new HttpCookie("Token", result.Token)
{
Expires = DateTime.Now.AddDays(10)
};
Response.Cookies.Add(cookie);
return Redirect("/home/index");
///拿掉地址栏Token因为特别不安全。
///小王xxx系统的地址是多少。。。然后账号就
}
else
{
return View(result);
}
}
public ActionResult Logout()
{
AuthUtil.Logout();
return Redirect("/Home/Index");
}
}
}