예제 #1
1
 public void RaiseCallbackEvent(string eventArgument)
 {
     //匿名用户登录
     if (String.IsNullOrEmpty(eventArgument)) {
         FormsAuthentication.SetAuthCookie("Anonymous", true);
         callBackResult = FormsAuthentication.DefaultUrl;
         WriteLoginLog("Anonymous");
         return;
     }
     String[] arguments = eventArgument.Split(',');
     String userAccount = arguments[0];
     String password = FormsAuthentication.HashPasswordForStoringInConfigFile(arguments[1], "MD5");
     using (SysUserBusiness user = new SysUserBusiness()) {
         bool passed = user.Authentication(userAccount, password);
         if (passed) {
             FormsAuthentication.SetAuthCookie(userAccount, true);
             HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userAccount, true);
             FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
             FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, "");
             authCookie.Value = FormsAuthentication.Encrypt(newTicket);
             Response.Cookies.Add(authCookie);
             callBackResult = FormsAuthentication.DefaultUrl;
             WriteLoginLog(userAccount);
         }
     }
 }
예제 #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        String userAccount = txtUsername.Text.Trim();
        String password    = txtPassword.Text.Trim();

        if (String.IsNullOrWhiteSpace(userAccount) || String.IsNullOrWhiteSpace(password))
        {
            String js = "alert('用户名或密码错误请重新输入!');";
            ClientScript.RegisterClientScriptBlock(GetType(), "Msg", js, true);
        }
        password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
        using (SysUserBusiness user = new SysUserBusiness()) {
            bool passed = user.Authentication(userAccount, password);
            if (passed)
            {
                FormsAuthentication.SetAuthCookie(userAccount, true);
                HttpCookie authCookie               = FormsAuthentication.GetAuthCookie(userAccount, true);
                FormsAuthenticationTicket ticket    = FormsAuthentication.Decrypt(authCookie.Value);
                FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, "");
                authCookie.Value = FormsAuthentication.Encrypt(newTicket);
                Response.Cookies.Add(authCookie);
                callBackResult = FormsAuthentication.DefaultUrl;
                Server.Transfer(FormsAuthentication.DefaultUrl);
            }
            else
            {
                String js = "alert('用户名或密码错误请重新输入!');";
                ClientScript.RegisterClientScriptBlock(GetType(), "Msg", js, true);
            }
        }
        //FormsAuthentication.SetAuthCookie(userAccount, true);
        //Server.Transfer(FormsAuthentication.DefaultUrl);
    }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (SysUserBusiness Business = new SysUserBusiness()) {
         String pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPassword.Text, "MD5");
         bool passed = Business.Authentication(UserNo, pwd);
         if (!passed) {
             ShowMessage("旧密码输入错误请重新输入!");
         }
         if (passed) {
             pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtConfirmPassword.Text, "MD5");
             Business.ChangedPassword(UserNo, pwd);
             ShowMessage("恭喜你,修改密码成功!");
         }
     }
 }
예제 #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     using (SysUserBusiness Business = new SysUserBusiness()) {
         String pwd    = FormsAuthentication.HashPasswordForStoringInConfigFile(txtOldPassword.Text, "MD5");
         bool   passed = Business.Authentication(UserAccount, pwd);
         if (!passed)
         {
             ShowMessage("旧密码输入错误请重新输入!");
         }
         if (passed)
         {
             pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtConfirmPassword.Text, "MD5");
             Business.ChangedPassword(UserAccount, pwd);
             ShowMessage("恭喜你,修改密码成功!");
         }
     }
 }
예제 #5
0
    public void RaiseCallbackEvent(string eventArgument)
    {
        String[] arguments   = eventArgument.Split(',');
        String   userAccount = arguments[0];
        String   password    = FormsAuthentication.HashPasswordForStoringInConfigFile(arguments[1], "MD5");

        using (SysUserBusiness user = new SysUserBusiness()) {
            bool passed = user.Authentication(userAccount, password);
            if (passed)
            {
                FormsAuthentication.SetAuthCookie(userAccount, true);
                HttpCookie authCookie               = FormsAuthentication.GetAuthCookie(userAccount, true);
                FormsAuthenticationTicket ticket    = FormsAuthentication.Decrypt(authCookie.Value);
                FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, "");
                authCookie.Value = FormsAuthentication.Encrypt(newTicket);
                Response.Cookies.Remove(authCookie.Name);
                Response.Cookies.Add(authCookie);
                callBackResult = FormsAuthentication.DefaultUrl;
            }
        }
        //FormsAuthentication.SetAuthCookie("Admin", true);
        //Server.Transfer(FormsAuthentication.DefaultUrl);
        //callBackResult = FormsAuthentication.DefaultUrl;
    }