Esempio n. 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //if (txtEmail.Text != "*****@*****.**")
            //{
            //    lblErrorMessage.Text = "";
            //    lblSuccess.Text = "Website under maintenance mode";
            //    return;
            //}

            AccountConnection connection = new AccountConnection();

            //Check if the user exists in the unconifirmed accounts
            if (connection.unconfirmedAccount(txtEmail.Text))
            {
                lblErrorMessage.Text = "Please check your Inbox folder for confirmation email";
                lblSuccess.Text      = "";
            }
            else
            {
                Student s = connection.loginStudent(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                if (s != null)
                {
                    Session["STUDENT"] = s;

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Student"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Student/students-profile.aspx");
                }
                else if (connection.correctShopOwner(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["SHOPOWNER"] = connection.loginShopOwner(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Shop"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Shop/Home.aspx");
                }
                else if (connection.correctEventPoster(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["EVENTPOSTER"] = connection.loginEventPoster(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("EventPoster"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/EventPoster/Home.aspx");
                }
                else if (connection.correctSociety(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["SOCIETY"] = connection.loginSociety(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Society"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Society/Home.aspx");
                }
                else if (connection.correctCompany(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["COMPANY"] = connection.loginCompany(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Company"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Company/Home.aspx");
                }
                else if (connection.correctPropertyManager(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text)))
                {
                    Session["PROPERTYMANAGER"] = connection.loginPropertyManager(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text));

                    if (Request.QueryString["page"] != null && Request.QueryString["page"].ToString().Contains("Accommodation"))
                    {
                        Response.Redirect("~/Web/" + Request.QueryString["page"].ToString());
                    }

                    Response.Redirect("~/Web/Users/Accommodation/landlord-my-rooms.aspx");
                }
                else if (txtPassword.Text == "2g@63po" && txtEmail.Text == "*****@*****.**")
                {
                    //connection.adminAccess(txtEmail.Text, Secrecy.HashPassword(txtPassword.Text))
                    Session["ADMIN"] = "*****@*****.**";
                    Response.Redirect("~/Web/Users/Admin/ListOfUsers.aspx");
                }
                else
                {
                    lblErrorMessage.Text = "Email or Password is incorrect";
                    lblSuccess.Text      = "";
                }
            }
        }