Esempio n. 1
0
        protected void HandleClickLogin(object sender, EventArgs e)
        {
            string email    = tbEmail.Text.Trim();
            string password = tbPassword.Text.Trim();

            UsersDTO result = AuthBLL.Login(email, password);

            if (result != null)
            {
                Session["id"]    = result.ID;
                Session["name"]  = result.Name;
                Session["email"] = result.Email;
                Session["role"]  = result.Role;

                if (result.Role.Equals(Role.Admin))
                {
                    Response.Redirect("/dashboard");
                }
                else
                {
                    Response.Redirect("/");
                }
            }
            else
            {
                lbError.Visible = true;
            }
        }
Esempio n. 2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            bool     isLogin;
            User     user    = new User();
            IAuthBLL authBLL = new AuthBLL();

            isLogin = authBLL.Login(txtUser.Text, txtPassword.Text, ref user);

            if (isLogin)
            {
                Program.user = user;
                MessageBox.Show("Berhasil Login");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("User Name atau Password Salah");
            }
        }
Esempio n. 3
0
        // 点击登录
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = uname.Text.Trim();
            string userPwd  = pswd.Text.Trim();
            string pwdMd5   = new Cryptographys().MD5Encrypt(userPwd);

            string ip    = DNRequest.GetIP();
            string agent = HttpContext.Current.Request.UserAgent;
            var    bll   = new AuthBLL();

            TokenDto token  = new TokenDto();
            var      result = bll.Login(userName, userPwd, agent, ip, out token);

            if (result == ERROR_CODE.SUCCESS)
            {
                Common.WriteCookie("Token", "DoneNOW", token.token);
                Application["isFromLogin"] = "******";
                Response.Redirect("index.aspx");
            }
            else
            {
                if (result == ERROR_CODE.PARAMS_ERROR)
                {
                    msgtip.InnerHtml = "请使用邮箱或手机号登录!";
                }
                if (result == ERROR_CODE.PASSWORD_ERROR)
                {
                    msgtip.InnerHtml = "密码错误!";
                }
                if (result == ERROR_CODE.USER_NOT_FIND)
                {
                    msgtip.InnerHtml = "输入用户不存在!";
                }
                if (result == ERROR_CODE.LOCK)
                {
                    msgtip.InnerHtml = "您的账户已被锁定,登录失败";
                }
                msgtip.Visible = true;
            }

            /*
             * var result = bll.Login(userName, userPwd, ip, agent, out user);
             * if (result== DTO.ERROR_CODE.SUCCESS)
             * {
             *  Session["dn_session_user_info"] = user;
             *  Session["dn_session_user_permits"] = bll.GetUserPermit(user.id);
             *  EMT.Tools.Common.WriteCookie("UserName", "DoneNOW", userName);
             *  EMT.Tools.Common.WriteCookie("UserPwd", "DoneNOW", pwdMd5);
             *  Response.Redirect("index.aspx");
             * }
             * else
             * {
             *  if (result == ERROR_CODE.PARAMS_ERROR)
             *      msgtip.InnerHtml = "请使用邮箱或手机号登录!";
             *  if (result == ERROR_CODE.PASSWORD_ERROR)
             *      msgtip.InnerHtml = "密码错误!";
             *  if (result == ERROR_CODE.USER_NOT_FIND)
             *      msgtip.InnerHtml = "输入用户不存在!";
             *  msgtip.Visible = true;
             * }
             */
        }