Exemplo n.º 1
0
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            //System.Diagnostics.Debugger.Launch();
            try
            {
                if (_pagevalid)
                {
                    _blluser = new BllUser();
                    _dtouser = new DtoUser();

                    var emailRegex    = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                    var passwordRegex = new Regex("^([a-zA-Z0-9@*#]{8,15})$");


                    if (emailRegex.IsMatch(TxtLEmail.Text) &&
                        passwordRegex.IsMatch(TxtLPassword.Text))
                    {
                        _dtouser.Email    = Convert.ToString(TxtLEmail.Text);
                        _dtouser.Password = Convert.ToString(TxtLPassword.Text);
                        _dtouser.IsUser   = true;
                        // _dtouser.IsUser = chkuser.SelectedValue == "1" ? true : false;

                        _userid = _blluser.AuthenticateUser(_dtouser);

                        if (_userid == -1 || _userid == 0)
                        {
                            LblAutentication.Text    = "Incorrect Username Or Password";
                            LblAutentication.Visible = true;
                        }
                        else if (_userid == -2)
                        {
                            LblAutentication.Text    = "Please verify you email";
                            LblAutentication.Visible = true;
                        }
                        else
                        {
                            _cookie = new HttpCookie("Tagged");
                            _cookie.Values.Add("d", UtilityClass.EncryptStringAES(_userid.ToString()));
                            _cookie.Values.Add("u", UtilityClass.EncryptStringAES(1.ToString()));

                            _cookie.Expires = DateTime.MaxValue;
                            Response.SetCookie(_cookie);
                            // Get a ClientScriptManager reference from the Page class.
                            var cs = Page.ClientScript;

                            // Check to see if the startup script is already registered.
                            if (!cs.IsStartupScriptRegistered(GetType(), "ClosePopupScript"))
                            {
                                var cstext1 = "ClosePopup()";
                                Page.ClientScript.RegisterStartupScript(GetType(), "closed",
                                                                        "<script type='text/javascript'>ClosePopup('" + _prevurl + "')</script>");
                            }
                        }
                    }
                    else
                    {
                        LblAutentication.Text    = "Incorrect Username Or Password";
                        LblAutentication.Visible = true;
                    }
                }
                else
                {
                    LblAutentication.Visible = true;
                    LblAutentication.Text    = "Captcha Does Match";
                }
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }
Exemplo n.º 2
0
        protected void btnweblogin_Click(object sender, EventArgs e)
        {
            try
            {
                // System.Diagnostics.Debugger.Launch();
                _blluser = new BllUser();
                _dtouser = new DtoUser();

                var emailRegex    = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                var passwordRegex = new Regex("^([a-zA-Z0-9@*#]{8,15})$");

                if (emailRegex.IsMatch(txtwebemail.Text) &&
                    passwordRegex.IsMatch(txtwebpassword.Text))
                {
                    _dtouser.Email    = Convert.ToString(txtwebemail.Text);
                    _dtouser.Password = Convert.ToString(txtwebpassword.Text);
                    _dtouser.IsUser   = false;
                    // _dtouser.IsUser = chkuser.SelectedValue == "1" ? true : false;

                    _userid = _blluser.AuthenticateUser(_dtouser);

                    if (_userid == -1 || _userid == 0)
                    {
                        lblwebauthentication.Text    = "Incorrect Username Or Password";
                        lblwebauthentication.Visible = true;
                        Page.ClientScript.RegisterStartupScript(GetType(), "showwebtab",
                                                                "<script type='text/javascript'>$('#myTab a:last').tab('show');</script>");
                    }
                    else if (_userid == -2)
                    {
                        lblwebauthentication.Text    = "Please verify you email";
                        lblwebauthentication.Visible = true;
                        Page.ClientScript.RegisterStartupScript(GetType(), "showwebtab",
                                                                "<script type='text/javascript'>$('#myTab a:last').tab('show');</script>");
                    }
                    else
                    {
                        _cookie = new HttpCookie("Tagged");
                        _cookie.Values.Add("d", UtilityClass.EncryptStringAES(_userid.ToString()));
                        _cookie.Values.Add("u", UtilityClass.EncryptStringAES(0.ToString()));

                        _cookie.Expires = DateTime.MaxValue;
                        Response.SetCookie(_cookie);
                        // Get a ClientScriptManager reference from the Page class.
                        var cs = Page.ClientScript;

                        // Check to see if the startup script is already registered.
                        if (!cs.IsStartupScriptRegistered(GetType(), "ClosePopupScript"))
                        {
                            var cstext1 = "ClosePopup()";
                            Page.ClientScript.RegisterStartupScript(GetType(), "closed",
                                                                    "<script type='text/javascript'>ClosePopup('../WebsiteAdmin/WebsiteGeneralSetting.aspx')</script>");
                        }
                    }
                }
                else
                {
                    lblwebauthentication.Text    = "Incorrect Username Or Password";
                    lblwebauthentication.Visible = true;
                    Page.ClientScript.RegisterStartupScript(GetType(), "showwebtab",
                                                            "<script type='text/javascript'>$('#myTab a:last').tab('show');</script>");
                }
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }