/// <summary> /// 用户认证 /// </summary> /// <param name="authPackage"></param> /// <returns></returns> public virtual string AuthenticateUser(IAuthPackage authPackage) { AuthMessage am = new AuthMessage(); am.LoginName = authPackage.LoginName; am.Password = authPackage.Password; am.PasswordEncrypted = authPackage.PasswordEncrypted; am.AuthType = authPackage.AuthType; am.IP = authPackage.IP; string sid = USService.AuthenticateUser(am.ToString()); return(sid); }
public string AuthenticateUser(IAuthPackage authPackage) { DataForm df = new DataForm(); df.SetValue("LoginName", authPackage.LoginName); df.SetValue("Password", authPackage.Password); string sid = USServiceClient.CreateUserState(df.ToString(), string.Empty, string.Empty, string.Empty, string.Empty); if (!String.IsNullOrEmpty(sid) && sid.Length >= 30) { SetAuthenticationTicket(sid, authPackage.LoginName); } return(sid); }
/// <summary> /// 用户认证 /// </summary> /// <param name="authPackage"></param> /// <returns></returns> public override string AuthenticateUser(IAuthPackage authPackage) { string sid = base.AuthenticateUser(authPackage); if (!String.IsNullOrEmpty(sid) && sid.Length >= 30) { // 判断返回的是否用户状态 HttpCookie authCookie = FormsAuthentication.GetAuthCookie(authPackage.LoginName, false); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket( ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, sid); authCookie.Value = FormsAuthentication.Encrypt(newTicket); HttpContext.Current.Response.Cookies.Add(authCookie); } return(sid); }