mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 18:47:55 +08:00
增加SSO逻辑
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace Infrastructure.Helper
|
||||
namespace Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// Cookie帮助类
|
||||
@@ -68,5 +68,45 @@ namespace Infrastructure.Helper
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get cookie expiry date that was set in the cookie value
|
||||
/// </summary>
|
||||
/// <param name="cookie"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetExpirationDate(HttpCookie cookie)
|
||||
{
|
||||
if (String.IsNullOrEmpty(cookie.Value))
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
string strDateTime = cookie.Value.Substring(cookie.Value.IndexOf("|") + 1);
|
||||
return Convert.ToDateTime(strDateTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set cookie value using the token and the expiry date
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="minutes"></param>
|
||||
/// <returns></returns>
|
||||
public static string BuildCookueValue(string value, int minutes)
|
||||
{
|
||||
return String.Format("{0}|{1}", value, DateTime.Now.AddMinutes(minutes).ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads cookie value from the cookie
|
||||
/// </summary>
|
||||
/// <param name="cookie"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCookieValue(HttpCookie cookie)
|
||||
{
|
||||
if (String.IsNullOrEmpty(cookie.Value))
|
||||
{
|
||||
return cookie.Value;
|
||||
}
|
||||
return cookie.Value.Substring(0, cookie.Value.IndexOf("|"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user