Example #1
0
        public bool UpdatePassword(string oldpwd, string newpwd)
        {
            dt = (DataTable)this.Session["currentuser"];
            string emailid   = dt.Rows[0]["Email"].ToString();
            string userid    = dt.Rows[0]["Uid"].ToString();
            string validuser = LoginUser(emailid, oldpwd);

            if (validuser != "nouser")
            {
                string newpassword = CLASS.PasswordEncryption.EncryptIt(newpwd);
                try
                {
                    IUser updatepassword = new UserItems();
                    bool  ispwdupdated   = updatepassword.UpdatePassword(userid, newpassword);
                    return(ispwdupdated);
                }
                catch
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string uname       = txt_emailid.Text;
            string oldpassword = CLASS.PasswordEncryption.EncryptIt(txt_oldpwd.Text);
            string newpassword = CLASS.PasswordEncryption.EncryptIt(txt_newpwd.Text);

            try
            {
                IUser checkuser = new UserItems();

                //returns a table if given email id and password are matched
                dt = checkuser.checklogin(uname, oldpassword);
                if (dt != null)
                {
                    string userid       = dt.Rows[0]["Uid"].ToString();
                    bool   ispwdupdated = checkuser.UpdatePassword(userid, newpassword);
                    if (ispwdupdated)
                    {
                        lbl_submit.Text = HardCodedValues.BuddaResource.PwdChangeSuccess;
                    }
                    else
                    {
                        lbl_submit.Text = HardCodedValues.BuddaResource.Error;
                    }
                }
                else
                {
                    lbl_submit.Text = HardCodedValues.BuddaResource.LoginFail;
                }
            }
            catch (Exception ex)
            {
                lbl_submit.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message;
            }
        }
Example #3
0
        protected void btn_fsubmit_Click(object sender, EventArgs e)
        {
            //check whether the entered captcha text is matched or not
            if (this.txt_captcha.Text == this.Session["CaptchaImageText"].ToString())
            {
                string emailid = txt_femailid.Text;
                try
                {
                    IUser checkuser = new UserItems();

                    //returns table if given email id exists
                    dt = checkuser.checkavailability(emailid);
                    if (dt == null)
                    {
                        lbl_femailid.Text = HardCodedValues.BuddaResource.EmailIdNull;
                        // Create a random Captcha and store it in the Session object.
                        this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(HardCodedValues.BudhaConstants.RandomPasswordLength);
                        lbl_captcha.Text = string.Empty;
                    }
                    else
                    {
                        //if email id exists, then generate a new random password
                        string newpwd = GenerateRandomPassword(HardCodedValues.BudhaConstants.RandomPasswordLength);

                        //encrypt the given password to store in database
                        string encryptedpwd = CLASS.PasswordEncryption.EncryptIt(newpwd);

                        //update the new password in database
                        bool ispwdupdated = checkuser.UpdatePassword(emailid, encryptedpwd);
                        if (ispwdupdated)
                        {
                            //send the new password to the user email id
                            sendEmail(emailid, newpwd);

                            lbl_fsubmit.Text      = HardCodedValues.BuddaResource.PwdForgotSuccess;
                            lbl_fsubmit.Font.Bold = true;
                        }
                        else
                        {
                            lbl_fsubmit.Text = HardCodedValues.BuddaResource.Error;
                        }
                    }
                }
                catch (Exception ex)
                {
                    lbl_fsubmit.Text = HardCodedValues.BuddaResource.CatchBlockError + ex.Message;
                }
            }
            else
            {
                txt_captcha.Text = "";
                lbl_captcha.Text = HardCodedValues.BuddaResource.CaptchaError;
                // Create a random Captcha and store it in the Session object.
                this.Session["CaptchaImageText"] = Captcha.CaptchaImage.GenerateRandomCode(7);
                txt_captcha.Focus();
            }
        }