Exemplo n.º 1
0
 protected void btn_changepwd_Click(object sender, EventArgs e)
 {
     if (txt_newpwd.Text == txt_confirmnewpwd.Text)
     {
         if (OperData.ChkPwdPower(txt_confirmnewpwd.Text.Trim()))
         {
             string id = EnDecrypt.Decrypt(hf_id.Value);
             if (OperData.changepwd(id, txt_newpwd.Text.Trim()))
             {
                 Response.Write("<script language=javascript>alert('Password has been changed successfully!Your account has been activated !');window.location.href='login.aspx';</script>");
             }
             else
             {
                 Response.Write("<script language=javascript>alert('Password is not changed properly!');</script>");
             }
         }
         else
         {
             lbl_msg.Text = "Must start with letters; At least include one uppercase, one lowercase and one number; No fewer than eight characters long";
         }
     }
     else
     {
         lbl_msg.Text = "Password and confirm password don't match";
     }
 }
        /// <summary>
        /// 普通用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            if (pwd.Value.Trim() != "" && inp_username.Value.Trim() != "") //用户邮箱和密码
            {
                if (OperData.loginedByEmail(inp_username.Value.Trim(), pwd.Value.Trim()))
                {
                    //Response.Write("<script language=javascript>window.location.href='login.aspx';</script>");
                    Crystal_clear_logs log = new Crystal_clear_logs();
                    //   log.userId=OperData.QueryInfoByfirstname(inp_username.Value.Trim());
                    log.userId         = inp_username.Value.Trim();
                    log.action         = "login";
                    log.actionDatetime = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"));


                    log.actionDetails = "login in system";



                    // Session["userguid"] = OperData.QueryUserIDByfirstname(inp_username.Value.Trim());//
                    Session["userguid"] = OperData.QueryUserIDBymail(inp_username.Value.Trim());//通过用户邮箱查询id
                    //Session["username"] = inp_username.Value.Trim();
                    Session["UserEmail"] = inp_username.Value.Trim();
                    m_username           = OperData.QueryUserNameBymail(inp_username.Value.Trim());
                    Session["username"]  = m_username;
                    if (OperData.insertLog(log))
                    {
                        //     Response.Redirect("userweb.aspx?usname=" + m_username);
                        Response.Redirect("LoginedNUser.aspx?usname=" + m_username + "&userstyle=0");
                    }
                }
                else
                {
                    lbl_msg.Text = "User acount or password is invlaid!";
                }
            }



            //以下用于第二次登录时,记住用户上次登录时的域名
            HttpCookie cookie = new HttpCookie("USER_COOKIE");

            if (chk_remember.Checked)
            {
                cookie.Values.Add("UserEmail", this.inp_username.Value.Trim());
                cookie.Values.Add("UserName", m_username);
                cookie.Values.Add("UserPassword", this.pwd.Value.Trim());
                //cookie.Values.Add("myDomain", this.txt_Domain.Text.Trim());
                cookie.Expires = System.DateTime.Now.AddDays(7.0);
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            else
            {
                if (cookie != null)
                {
                    Response.Cookies["USER_COOKIE"].Expires = DateTime.Now;
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string token  = Request.QueryString["token"];
                string id_tmp = System.Web.HttpUtility.UrlEncode(Request.QueryString["id"], System.Text.UnicodeEncoding.UTF8);
                string id     = id_tmp.Replace("%3d", "=");
                if (token != "" && id != "")
                {
                    string de_id = EnDecrypt.Decrypt(id);
                    //user_nom = OperData.QueryIdByToken(token);
                    user_nom = OperData.QueryInfoByID(de_id);
                    if (user_nom != null)
                    {
                        string   first = user_nom.firstName;
                        DateTime tokenExpiredDatetime = user_nom.tokenExpiredDatetime; //有效期

                        string code = user_nom.registrationToken;                      //激活码
                        int    flag = user_nom.activited;                              //激活状态

                        DateTime curtime = DateTime.Now;



                        if (flag == 0 && curtime < tokenExpiredDatetime)
                        {
                            if (OperData.UpdateActiveByID(de_id))
                            {
                                //这就是打断点的方法
                                Response.Write("<script language=javascript>alert('Your account has been activated successfully!');window.location.href='active.aspx?id=" + id + "';</script>");
                            }
                            else
                            {
                                Response.Write("<script language=javascript>alert('Failed to activate!');window.location.href='login.aspx';</script>");
                            }
                        }
                        else
                        {
                            if (flag == 1)
                            {
                                Response.Write("<script language=javascript>alert('Account has been activated!');window.location.href='active.aspx?id=" + id + "';</script>");
                                return;
                            }

                            if (flag == 0 && curtime > tokenExpiredDatetime)
                            {
                                Response.Write("<script language=javascript>alert('Code expired, activate fail!');window.location.href='delaccount.aspx?id=" + id + "';</script>");
                                return;
                            }
                            else
                            {
                                Response.Write("<script language=javascript>alert('Error Link!');window.location.href='login.aspx';</script>");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void btn_active_Click(object sender, EventArgs e)
        {
            if (txt_regcode.Text != "" || txt_regcode.Text != null)
            {
                Response.Write("");
            }
            else
            {
                string token = txt_regcode.Text.Trim();
                if (token != "")
                {
                    user_nom = OperData.QueryIdByToken(token);
                    string   first = user_nom.firstName;
                    DateTime tokenExpiredDatetime = user_nom.tokenExpiredDatetime; //有效期
                    string   code = user_nom.registrationToken;                    //激活码
                    int      flag = user_nom.activited;                            //激活状态

                    DateTime curtime = DateTime.Now;
                    if (code == token && flag == 0 && curtime < tokenExpiredDatetime)
                    {
                        if (OperData.UpdateActive(token))
                        {
                            Response.Write("<script language=javascript>alert('Your account has been activated successfully!');window.location.href='active.aspx?token=" + token + "';</script>");
                        }
                        else
                        {
                            Response.Write("<script language=javascript>alert('Failed to activate!');window.location.href='login.aspx';</script>");
                        }
                    }
                    else
                    {
                        if (code == token && flag == 1)
                        {
                            Response.Write("<script language=javascript>alert('Your account has been activated successfully!');window.location.href='active.aspx?token=" + token + "';</script>");
                            return;
                        }

                        if (code == token && flag == 0 && curtime > tokenExpiredDatetime)
                        {
                            Response.Write("<script language=javascript>alert('Code expired, failed to activate!');window.location.href='login.aspx" + token + "';</script>");
                            return;
                        }
                        else
                        {
                            Response.Write("<script language=javascript>alert('Error Link!');window.location.href='login.aspx';</script>");
                        }
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string id_tmp = System.Web.HttpUtility.UrlEncode(Request.QueryString["id"], System.Text.UnicodeEncoding.UTF8);
         string id     = id_tmp.Replace("%3d", "=");
         // string token = Request.QueryString["id"];
         //UserInfo_Normal user = OperData.QueryIdByToken(token);
         string de_id = EnDecrypt.Decrypt(id);
         if (OperData.DelAccount(de_id))
         {
             Response.Write("<script language=javascript>alert('user had deleted  !');window.location.href='login.aspx';</script>");
         }
         else
         {
             Response.Write("<script language=javascript>alert('deleted user fail !');</script>");
         }
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string useremail = context.Request["user_email"];

            if ((useremail != null) || (useremail != ""))
            {
                if (OperData.ChkReEmail(useremail))
                {
                    context.Response.Write("Email address can be used");
                }
                else
                {
                    context.Response.Write("The email address already exsited ");
                }
            }
            else
            {
                context.Response.Write("Enqury error");
            }
        }
Exemplo n.º 7
0
        private bool isUser()
        {
            string userName     = txt_firstName.Text.Trim();
            string surname      = txt_surName.Text.Trim();
            string companycode  = txt_companyCode.Text.Trim();
            string mail         = txt_usermail.Text.Trim();
            string password     = "******";// txt_password.Text.Trim();
            string workphonenum = txt_workPhoneNumber.Text.Trim();

            user_norm = HaveUser(userName, mail);

            if (userName == "")
            {
                // Response.Write("用户名不能为空");
                lbl_msg.Text = "Username cannot be empty";
                return(false);
            }
            if (surname == "")
            {
                lbl_msg.Text = "Surname cannot be empty";
                return(false);
            }
            if (password == "")
            {
                //Response.Write("密码不能为空");
                lbl_msg.Text = "Password cannot be empty";
                return(false);
            }
            if (companycode == "")
            {
                lbl_msg.Text = "Company code cannot be empty";
                return(false);
            }
            if (workphonenum == "")
            {
                // Response.Write("邮箱不能为空");
                lbl_msg.Text = "Work phnoe number cannot be empty";
                return(false);
            }
            if (mail == "")
            {
                // Response.Write("邮箱不能为空");
                lbl_msg.Text = "Email address cannot be empty";
                return(false);
            }
            if (userName == user_norm.firstName)
            {
                // Response.Write("用户名已存在");
                lbl_msg.Text = "Username already exists";
                return(false);
            }

            //检查邮箱是否已注册
            if (OperData.ChkReEmail(mail))
            //if (mail == user_norm.emailAddress)
            {
                //Response.Write("邮箱已存在");

                return(true);
            }
            else
            {
                userName     = "";
                surname      = "";
                companycode  = "";
                mail         = "";
                password     = "";
                workphonenum = "";
                lbl_msg.Text = "The mailbox already exists";
                return(false);
            }
        }
        //雇员登录
        protected void btn_EmployeeLogin_Click(object sender, EventArgs e)
        {
            //Response.Redirect("CurrentUser.aspx?userstyle=1&usname=" + inp_username.Value + "&[email protected]&usphone=135728744444");


            try
            {
                #region
                //AD 域用户登录
                string mydomain = myDomain.Value;
                m_username = inp_username.Value;
                string         FilterStr;//
                DirectoryEntry entry = new DirectoryEntry("LDAP://" + "kerrylogistics.com", m_username, this.pwd.Value);

                DirectorySearcher Seacher = new DirectorySearcher(entry);
                FilterStr      = "(&(objectClass=user) (sAMAccountName=" + m_username + "))";
                Seacher.Filter = FilterStr;
                SearchResult Result = Seacher.FindOne();
                UserInfo     us     = new UserInfo();

                StringBuilder strtemp = new StringBuilder();
                if (Result == null)
                {
                    Response.Write("<script language=javascript>alert('username or password error!if you'r a new user ,please click Login!');</script>");
                }
                else
                {
                    foreach (string userkey in Result.Properties.PropertyNames)
                    {
                        foreach (object obj in Result.Properties[userkey])
                        {
                            strtemp.Append(userkey + ":" + obj.ToString() + "\r\n");
                            switch (userkey)
                            {
                            case "objectsid":
                                byte[] guid = ObjToByte(obj);
                                us.objectguid = Convert.ToBase64String(guid);
                                break;

                            case "samaccountname": us.name = obj.ToString(); break;

                            case "mail": us.mail = obj.ToString(); break;

                            case "telephonenumber": us.telephonenumber = obj.ToString(); break;

                            default: break;
                            }
                        }
                    }


                    entry.AuthenticationType = AuthenticationTypes.Secure;



                    Crystal_clear_logs log = new Crystal_clear_logs();
                    // log.userId = us.objectguid;


                    log.userId         = us.name;//新加userID记录username
                    log.action         = "login";
                    log.actionDatetime = DateTime.Now;
                    //log.actionDatetime = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
                    log.actionDetails = "login in system";



                    if (OperData.insertLog(log))
                    {
                        Session["userguid"] = us.objectguid.Trim();
                        Session["username"] = us.name.Trim();//存储用户编号

                        HttpCookie cookie = new HttpCookie("USER_COOKIE");
                        if (chk_remember.Checked)
                        {
                            cookie.Values.Add("UserName", this.inp_username.Value.Trim());
                            cookie.Values.Add("UserPassword", this.pwd.Value.Trim());
                            cookie.Values.Add("myDomain", this.myDomain.Value.Trim());
                            cookie.Expires = System.DateTime.Now.AddDays(7.0);
                            HttpContext.Current.Response.Cookies.Add(cookie);
                        }
                        else
                        {
                            if (cookie != null)
                            {
                                Response.Cookies["USER_COOKIE"].Expires = DateTime.Now;
                            }
                        }


                        // Response.Redirect("register.aspx?usname=" + us.name + "&usmail=" + us.mail + "&usphone=" + us.telephonenumber);
                        //  Response.Redirect("LoginedUser.aspx?userstyle=1&usname=" + us.name + "&usmail=" + us.mail + "&usphone=" + us.telephonenumber);
                        Response.Redirect("CurrentUser.aspx?userstyle=1&usname=" + us.name + "&usmail=" + us.mail + "&usphone=" + us.telephonenumber);
                    }
                    else
                    {
                        Response.Write("<script language=javascript>alert('AD login fail!');</script>");
                    }
                }
                #endregion


                //模拟用户登录

                //if (txt_username.Text != "")
                //{
                //    string userguid = "14545545";
                //    string sql_insert_log = "insert into crystal_clear_logs (userId,action,actionDetails,actionDatetime) values('" + userguid + "','" + "login','" + "login in system','" + DateTime.Now + "')";
                //    int res = DBHelp.ExecuteCommand(sql_insert_log);
                //    if (res > 0)
                //    {
                //        Session["username"] = txt_username.Text.Trim();//存储用户编号
                //        Response.Redirect("register.aspx?usname=" + txt_username.Text + "&usmail=" + "*****@*****.**" + "&usphone=" + "13577889988");
                //    }
                //    else
                //    {
                //        Response.Write("<script language=javascript>alert('Insert log fail!');</script>");
                //    }
                //}
            }
            catch (Exception ex)
            {
                string Str = ex.Message;

                lbl_msg.Text = Str;
            }
        }