Beispiel #1
0
        protected void login_click(object sender, EventArgs e)
        {
            string email    = txt_email_login.Text;
            string password = txt_password_login.Text;

            if ((!string.IsNullOrWhiteSpace(email)) && (!string.IsNullOrWhiteSpace(password)))
            {
                CompanyRepo CompanyRepo = new CompanyRepo();
                string      result      = CompanyRepo.Authentication(email, password);
                if (result.Equals("true"))
                {
                    FormsAuthentication.RedirectFromLoginPage(email, Persist.Checked);
                    string ReturnUrl = Request.QueryString["ReturnUrl"];
                    Session["userType"]  = "company";
                    Session["userEmail"] = email;
                    if ((!string.IsNullOrWhiteSpace(ReturnUrl)))
                    {
                        Response.Redirect(ReturnUrl.Trim());
                    }
                    else
                    {
                        Response.Redirect("users.aspx");
                    }
                }

                if (result.Equals("wrong"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Invalid email or password.');", true);
                    return;
                }

                if (result.Equals("not confirm"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('User not confirm by admin.');", true);
                    return;
                }

                if (result.Equals("false"))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Something went wrong.');", true);
                    return;
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Email and password are required.');", true);
                return;
            }
        }