修改部分文件结构,完善第三方登陆功能

This commit is contained in:
yubaolee
2016-07-12 12:28:54 +08:00
parent 994ab81ebb
commit 5f08a59f27
45 changed files with 10078 additions and 246 deletions

View File

@@ -18,6 +18,15 @@ using OpenAuth.App.ViewModel;
namespace OpenAuth.App.SSO
{
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>¼<EFBFBD><C2BC>֤<EFBFBD><D6A4>
/// <para><3E><>¼ʱ<C2BC><CAB1></para>
/// <code>
/// var result = AuthUtil.Login(AppKey, username, password);
/// if (result.Success)
/// return Redirect("/home/index?Token=" + result.Token);
/// </code>
/// </summary>
public class AuthUtil
{
static HttpHelper _helper = new HttpHelper(ConfigurationManager.AppSettings["SSOPassport"]);
@@ -25,23 +34,23 @@ namespace OpenAuth.App.SSO
private static string GetToken()
{
string token = HttpContext.Current.Request.QueryString["Token"];
if (!string.IsNullOrEmpty(token)) return token;
if (!String.IsNullOrEmpty(token)) return token;
var cookie = HttpContext.Current.Request.Cookies["Token"];
return cookie == null ? string.Empty : cookie.Value;
return cookie == null ? String.Empty : cookie.Value;
}
public static bool CheckLogin(string token, string remark = "")
{
if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(GetToken()))
if (String.IsNullOrEmpty(token) || String.IsNullOrEmpty(GetToken()))
return false;
var requestUri = string.Format("/SSO/Check/GetStatus?token={0}&requestid={1}", token, remark);
var requestUri = String.Format("/SSO/Check/GetStatus?token={0}&requestid={1}", token, remark);
try
{
var value = _helper.Get(null, requestUri);
return bool.Parse(value);
return Boolean.Parse(value);
}
catch (Exception ex)
{
@@ -49,15 +58,26 @@ namespace OpenAuth.App.SSO
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>¼״̬
/// <para>ͨ<><CDA8>URL<52>е<EFBFBD>Token<65><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cookie<69>е<EFBFBD>Token</para>
/// </summary>
/// <param name="remark"><3E><>ע<EFBFBD><D7A2>Ϣ</param>
public static bool CheckLogin(string remark="")
{
return CheckLogin(GetToken(), remark);
}
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>¼<EFBFBD><C2BC><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
/// <para>ͨ<><CDA8>URL<52>е<EFBFBD>Token<65><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Cookie<69>е<EFBFBD>Token</para>
/// </summary>
/// <param name="remark">The remark.</param>
/// <returns>LoginUserVM.</returns>
public static LoginUserVM GetCurrentUser(string remark = "")
{
var requestUri = string.Format("/SSO/Check/GetUser?token={0}&requestid={1}", GetToken(), remark);
var requestUri = String.Format("/SSO/Check/GetUser?token={0}&requestid={1}", GetToken(), remark);
try
{
@@ -79,7 +99,7 @@ namespace OpenAuth.App.SSO
/// <returns>System.String.</returns>
public static LoginResult Login(string appKey, string username, string pwd)
{
var requestUri = "/SSO/Login/Check";
var requestUri = "/SSO/Check/Login";
try
{
@@ -106,9 +126,9 @@ namespace OpenAuth.App.SSO
public static bool Logout()
{
var token = GetToken();
if (string.IsNullOrEmpty(token)) return true;
if (String.IsNullOrEmpty(token)) return true;
var requestUri = string.Format("/SSO/Login/Logout?token={0}&requestid={1}", token, "");
var requestUri = String.Format("/SSO/Login/Logout?token={0}&requestid={1}", token, "");
try
{