Пример #1
0
/*
 */
        private void DoLogin()
        {
            classes.Login clsLogin = new classes.Login();
            if (clsLogin.DoLogin(txtUsername.Text, txtPassword.Text, true, false))
            {
                //Set cookie
                if (chkRememberMe.Checked)
                {
                    SetCookie();
                }
                //Destroy the cookie with previous data
                else
                {
                    DestroyCookie();
                }

                //TODO: fixfixfix
                if (Session["EmailId"].ToString() == "*****@*****.**")
                {
                    Response.Redirect("Admin/Admin.aspx", true);
                }

                if (Session["GoToURL"] != null)
                {
                    if (Session["GoToURL"].ToString() == string.Empty)
                    {
                        Response.Redirect("UserMenu.aspx", true);
                    }
                    else
                    {
                        string strGoURL = Session["GoToURL"].ToString();
                        Session["GoToURL"] = string.Empty;
                        Response.Redirect(strGoURL, true);
                    }
                }
            }
            //login failed
            else
            {
                //and destroy cookie
                if (!chkRememberMe.Checked)
                {
                    DestroyCookie();
                }
                lblMessage.Text        = " Wrong e-mail or password. ";
                lblMessage.BackColor   = Color.White;
                lblMessage.BorderColor = Color.Red;
                lblMessage.Visible     = true;
            }
        }
Пример #2
0
        public static bool CheckLoginCookies(bool hashMe)
        {
            string uName, uPass;

            if (HttpContext.Current.Request.Cookies["UserInfo"] != null)
            {
                uName = HttpContext.Current.Request.Cookies["UserInfo"]["sea"].ToString();
                uPass = HttpContext.Current.Request.Cookies["UserInfo"]["monkey"].ToString();

                classes.Login clsLogin = new classes.Login();
                if (clsLogin.DoLogin(uName, uPass, hashMe, false))
                {
                    return(true);
                }
                return(false);
            }
            else
            {
            }
            return(false);
        }
Пример #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            String strSQL;
            String myConnectString;

            // Put user code to initialize the page here
            Global.AuthenticateUser();

            Session["LoggedIn"] = "No";

            lnkSignIn.Text = Global.SetLnkSignIn();
            lnkSignUp.Text = Global.SetLnkSignUp();

            if (!Page.IsPostBack)
            {
                // Put user code to initialize the page here
                ErrorLog.ErrorRoutine(false, "Registered EmailId: " + Session["EmailId"].ToString());

                //Get DB connect string
                myConnectString = ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;;

                //***TODO: E-mail verfication & activation
                //***see contact us page

                strSQL = "Select * FROM tblUser WHERE txtEmail = '" + Session["EmailId"].ToString() + "'";
                SqlConnection myConnection = new SqlConnection(myConnectString);

                string usersId = "unknown";

                try
                {
                    myConnection.Open();
                    SqlCommand objCommand = new SqlCommand(strSQL, myConnection);

                    SqlDataReader objReader = null;
                    objReader = objCommand.ExecuteReader();

                    if (objReader.Read())
                    {
                        usersId = objReader["iD"].ToString();
                        //ErrorLog.ErrorRoutine(false, "userId:" + usersId);

                        //Create dirs
                        if (CreateUserDir(usersId))
                        {
                            //set userID
                            //Session["userId"] = usersId;
                            //Session["LoggedIn"] = "Yes";
                            //Session["BlogFlg"] = "N";
                            //Session["LoggedIn"] = "No";

                            lblMessage.Text = "Your account has been created.  An e-mail confirmation has been sent.";
                            SendCongratEmail();
                            NotifyBHEmail(usersId);

                            if (Session["ServiceId"] != null)
                            {
                                if (Session["ServiceId"].ToString() == "6" || Session["ServiceId"].ToString() == "7") //upgrade
                                {
                                    classes.Login clsLogin = new classes.Login();
                                    if (clsLogin.DoLogin(Session["EmailId"].ToString(), string.Empty, true, true))
                                    {
                                        Session["LoggedIn"] = "Yes";
                                        Response.Redirect("Pay/OrderForm.aspx", false);
                                    }
                                }
                            }
                            else
                            {
                                Session["LoggedIn"] = "No";
                                Session["EmailId"]  = null;
                                Session["acctType"] = null;
                                Session["pw"]       = null;
                            }
                        }
                        else
                        {
                            Session["LoggedIn"] = "No";
                            Session["EmailId"]  = null;
                            Session["acctType"] = null;
                            Session["pw"]       = null;
                            ErrorLog.ErrorRoutine(false, "Error creating user dirs");
                            lblMessage.Text = "Registration Failed.  Please close this browser and try again.";
                        }
                    }
                    else
                    {
                        ErrorLog.ErrorRoutine(false, "RegisterFinish:PageLoad:Couldn't locate user.");
                        classes.Email.SendErrorEmail("RegisterFinish:PageLoad:Couldn't locate user.");
                    }
                }

                catch (Exception ex)
                {
                    ErrorLog.ErrorRoutine(false, "RegisterFinish:PageLoad: " + ex.Message);
                    lblMessage.Text     = "Registration Failed.  Please close this browser and try again.";
                    Session["LoggedIn"] = "No";
                    Session["EmailId"]  = null;
                    Session["pw"]       = null;
                    Session["acctType"] = null;
                }

                finally
                {
                    myConnection.Close();
                }
            }
        }