예제 #1
0
        protected void btnUpdatePass_ServerClick(object sender, EventArgs e)
        {
            UserService.UserCRUDClient service = new UserService.UserCRUDClient();
            service.Open();
            Object[] ds = service.Authenticate(txtEmailAddress.Value, Security.HashPassword(txtOldPass.Value));
            service.Close();

            if (!(ds == null))
            {
                if (txtNewPass.Value.Equals(txtNewPassConfirm.Value))
                {
                    UserService.UserCRUDClient UserCRUDService = new UserService.UserCRUDClient();
                    UserCRUDService.Open();
                    int result = 0;
                    result = UserCRUDService.updateUserPassword(((UserData)Session["User"]).getID(), txtEmailAddress.Value, Security.HashPassword(txtOldPass.Value), Security.HashPassword(txtNewPassConfirm.Value));
                    UserCRUDService.Close();
                    if (result == 1)
                    {
                        Session["User"] = null;
                        changeCard();
                    }
                    else
                    {
                        invalidPassUpdate.InnerHtml = "<p>An error occured<br/>Please make sure you enter your correct email address and current password</p>";
                    }
                }
                else
                {
                    invalidPassUpdate.InnerHtml = "<p>Please make sure you confirm your new password</p>";
                }
            }
            else
            {
                invalidPassUpdate.InnerHtml = "<p>Invalid account details<br/>Please make sure you enter your current email address and password</p>";
            }
        }