Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            string regName = context.Request["UName"];
            string regPwd = context.Request["UPwd"];
            string regEmail = context.Request["UEmail"];

            UserInfoExt bllUserInfo = new UserInfoExt();
            Guid roles = new Guid("7e6573be-d49f-48f0-a9cd-1fe8d64a84a6"); //注册时写死为普通会员
            Model.UserInfo modelUserInfo = new Model.UserInfo();
            modelUserInfo.RoleID = roles;
            modelUserInfo.UserName = regName;
            modelUserInfo.Email = regEmail;
            modelUserInfo.Password = lv_Common.DEncrypt.DEncrypt.Encrypt(regPwd);
            modelUserInfo.LastLoginDate = DateTime.Now;
            modelUserInfo.CreateDate = DateTime.Now;
            modelUserInfo.ApprovedState = (int)BLL.TypeEnum.UserApprovedState.已审核; //注册就通过审核,否则无法跳转到用户后台

            bllUserInfo.Add(modelUserInfo);

            #region
            FormsAuthentication.SetAuthCookie(regName, true, FormsAuthentication.FormsCookiePath);
            FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(regName, true, 180);//3小时超时
            string HashTicket = FormsAuthentication.Encrypt(Ticket);
            HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
            context.Response.Cookies.Add(UserCookie);
            modelUserInfo.LastLoginDate = DateTime.Now;
            bllUserInfo.Update(modelUserInfo);
            context.Response.Write("yes");
            #endregion
        }
Beispiel #2
0
 /// <summary>
 /// 完成身份验证
 /// </summary>
 /// <param name="page">传入Page实例</param>
 /// <param name="userName">用户名</param>
 /// <param name="rememberMe">是否"记住我"</param>
 /// <param name="timeout">登录超时(单位分钟)</param>
 public static void RegisterTicket(string userName, bool rememberMe, int timeout)
 {
     UserInfoExt bllUserInfo = new UserInfoExt();
     Model.UserInfo modelUserInfo = bllUserInfo.GetUserByName(userName);
     FormsAuthentication.SetAuthCookie(userName, true, FormsAuthentication.FormsCookiePath);
     FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(userName, rememberMe, timeout);
     string HashTicket = FormsAuthentication.Encrypt(Ticket);
     HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
     HttpContext.Current.Response.Cookies.Add(UserCookie);
     modelUserInfo.LastLoginDate = DateTime.Now;
     bllUserInfo.Update(modelUserInfo);
 }