Clothes.UI/Model/IdentityManager.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Clothes.BLL;
using Clothes.IBLL;
using Clothes.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
namespace Clothes.UI.Model
{
/// <summary>
/// 身份标识业务管理类
/// </summary>
public class IdentityManager
{
/// <summary>
/// 保存用户信息
/// </summary>
/// <param name="user"></param>
public static void SaveUser(CLUser Cuser)
{
if (Cuser == null)
{
return;
}
// 序列化用户资料
string profileString = Cuser.Id.ToString();
// 生成身份票据
DateTime timeNow = DateTime.Now;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
Cuser.Id.ToString(),
timeNow,
timeNow.AddMonths(1),
false,
profileString,
FormsAuthentication.FormsCookiePath);
string ticketString = FormsAuthentication.Encrypt(ticket);
// 保存身份票据到Cookie
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, ticketString);
cookie.Expires = timeNow.AddMonths(1);
HttpContext.Current.Response.Cookies.Set(cookie);
}
/// <summary>
/// 读取用户信息
/// </summary>
/// <returns></returns>
public static CLUser ReadUser()
{
// 读取身份
string ticketString = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]?.Value;
if (string.IsNullOrWhiteSpace(ticketString))
{
return default;
}
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(ticketString);
string userData = ticket.UserData;
后面还有 15 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。