Exemplo n.º 1
0
    protected void btnResetPassword_Click(object sender, EventArgs e)
    {
        int user_id = Convert.ToInt32(Context.Items["UserID"]);

        if (txtPassword.Text == "")
        {
            lblMsgReset.Text = "<br><br>New password cannot be blank";
        }
        else if (txtPassword.Text.Length < 6)
        {
            lblMsgReset.Text = "<br><br>New password cannot be less than 6 characters";
        }
        else if (txtPassword.Text.Length > 15)
        {
            lblMsgReset.Text = "<br><br>New password cannot be longer than 15 characters";
        }
        else if (txtPassword.Text == txtPasswordConfirm.Text)
        {
            lblMsgReset.Text = "";
            qPtl_User user = new qPtl_User(user_id);

            user.PasswordResetCode = "";
            string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1");
            user.Password = password_for_storing;
            user.Update();

            lblMsgReset.Text = "Your password has been successfully reset.<br><br>";
        }
        else
        {
            lblMsgReset.Text = "<br><br>Passwords did not match";
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Convert.ToString(Context.Items["SessionID"])))
        {
            qPtl_Sessions session = new qPtl_Sessions(Convert.ToInt32(Context.Items["SessionID"]));
            if (session.SessionID > 0)
            {
                session.StopTime = DateTime.Now;
                session.Update();
            }

            qPtl_User user = new qPtl_User(Convert.ToInt32(Context.Items["UserID"]));
            if (user.UserID > 0)
            {
                DateTime last_time = new DateTime();
                last_time = Convert.ToDateTime(user.LastTimeSeen);
                if (!String.IsNullOrEmpty(Convert.ToString(user.LastTimeSeen)))
                {
                    user.LastTimeSeen = last_time.AddMinutes(-16);
                }
                user.Update();
            }
        }

        Session.Abandon();
        FormsAuthentication.SignOut();
        Response.Redirect("~/default.aspx", true);
    }
Exemplo n.º 3
0
    protected void btnResetPassword_Click(object sender, EventArgs e)
    {
        int user_id = 0;

        if (!String.IsNullOrEmpty(Request.QueryString["userID"]))
        {
            user_id = Convert.ToInt32(Request.QueryString["userID"]);
            if (txtPassword.Text == "")
            {
                lblMsgReset.Text = "<br><br>New password cannot be blank";
            }
            else if (txtPassword.Text.Length < 6)
            {
                lblMsgReset.Text = "<br><br>New password cannot be less than 6 characters";
            }
            else if (txtPassword.Text.Length > 15)
            {
                lblMsgReset.Text = "<br><br>New password cannot be longer than 15 characters";
            }
            else if (txtPassword.Text == txtPasswordConfirm.Text)
            {
                lblMsgReset.Text = "";
                qPtl_User user = new qPtl_User(user_id);

                if (user.PasswordResetCode == Request.QueryString["resetCode"])
                {
                    user.PasswordResetCode = "";
                    string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1");
                    user.Password = password_for_storing;
                    user.Update();
                    txtPassword.Visible        = false;
                    txtPasswordConfirm.Visible = false;
                    btnResetPassword.Visible   = false;
                    hplCancelReset.Visible     = false;

                    lblMsgReset.Text = "Your password has been successfully reset.<br><br> <a href=\"/logon.aspx\" class=\"btn\">Sign in now</a>";
                }
                else
                {
                    lblMsgReset.Text = "<br><br>This password reset code is no longer valid. Please request another one or contact support";
                }
            }
            else
            {
                lblMsgReset.Text = "<br><br>Passwords did not match";
            }
        }
        else
        {
            Response.Redirect("/default.aspx");
        }
    }