Redirect the user to the change password form.

@skipUpgrade
@return HTTPResponse
324743
protected function redirectToChangePassword()
    {
        // Since this form is loaded via an iframe, this redirect must be performed via javascript
        $changePasswordForm = ChangePasswordForm::create($this, 'ChangePasswordForm');
        $changePasswordForm->sessionMessage(
            _t('SilverStripe\\Security\\Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'),
            'good'
        );

        // Get redirect url
        $changePasswordURL = $this->addBackURLParam(Security::singleton()->Link('changepassword'));
        $changePasswordURLATT = Convert::raw2att($changePasswordURL);
        $changePasswordURLJS = Convert::raw2js($changePasswordURL);
        $message = _t(
            'SilverStripe\\Security\\CMSMemberLoginForm.PASSWORDEXPIRED',
            '<p>Your password has expired. <a target="_top" href="{link}">Please choose a new one.</a></p>',
            'Message displayed to user if their session cannot be restored',
            array('link' => $changePasswordURLATT)
        );

        // Redirect to change password page
        $response = HTTPResponse::create()
            ->setBody(<<<PHP
<!DOCTYPE html>
<html><body>
$message
<script type="application/javascript">
setTimeout(function(){top.location.href = "$changePasswordURLJS";}, 0);
</script>
</body></html>
PHP
        );
        return $response;
    }
879592
public function redirectOnSuccess() {
		$params = [];
		if (!empty($this->options['bypass_hidden_from_input'])) {
			foreach ($this->options['bypass_hidden_from_input'] as $v) {
				$params[$v] = $this->options['input'][$v] ?? '';
			}
		}
		if (!empty($this->options['collection_current_tab_id'])) {
			$params[$this->options['collection_current_tab_id']] = $this->form_link;
		}
		$url = \Application::get('mvc.full') . '?' . http_build_query2($params) . '#' . ($this->options['input']['__anchor'] ?? '');
		$this->redirect($url);
	}
193612
public function changePasswordAction()
    {
        $user = $this->getUser();
        if (!is_object($user) || !$user instanceof UserInterface) {
            $this->createAccessDeniedException('This user does not have access to this section.');
        }

        $this->get('session')->remove('_bruery_user.password_expire.' . $user->getId());

        $form = $this->container->get('bruery.user.change_password.form');
        $formHandler = $this->container->get('bruery.user.change_password.form.handler');

        $process = $formHandler->process($user);
        if ($process) {
            $this->setFlash('fos_user_success', 'change_password.flash.success');
            return $this->redirect($this->getRedirectionUrl($user));
        }

        $template = $this->get('bruery_core.template_loader')->getTemplates();

        return $this->render($template['bruery_user.template.change_password.form'], array('form' => $form->createView()));
    }
804439
def change_password
    unless current_user
      bounce_user
      return
    end

    @credential = current_user.credentials.
                               where(type:  'Credentials::Password').first
    if @credential
      # An old password is set, must verify it.
      if @credential.check_password params[:credential][:old_password]
        success = @credential.update_attributes change_password_params
      else
        success = false
        flash[:alert] = 'Incorrect old password. Please try again.'
      end
    else
      @credential = Credentials::Password.new change_password_params
      @credential.user = current_user
      success = @credential.save
    end
    respond_to do |format|
      if success
        format.html do
          redirect_to session_url, notice: 'Password updated'
        end
        format.json { head :no_content }
      else
        format.html { render action: :password_change }
        format.json { render json: { error: :invalid } }
      end
    end
  end
10488
public function changePassword(Request $request)
    {
        $this->validate(
            $request,
            [
                'old_password' => 'required',
                'new_password' => 'required|min:8',
            ]
        );

        if (!Hash::check($request->input('old_password'), Auth::user()->password)) {
            return redirect()->back()->withErrors([
                'old_password' => trans('mustard::account.password_incorrect'),
            ]);
        }

        if ($request->input('old_password') == $request->input('new_password')) {
            return redirect()->back()->withErrors([
                'new_password' => trans('mustard::account.password_same'),
            ]);
        }

        Auth::user()->password = Hash::make($request->input('new_password'));

        Auth::user()->save();

        Auth::user()->sendEmail(
            trans('mustard::account.password_changed'),
            'mustard::emails.account.password-changed'
        );

        return redirect()->back()->withStatus(trans('mustard::account.password_changed'));
    }
871876
public function patchDetails()
    {
        $input = Binput::only(['first_name', 'last_name', 'email']);

        $val = UserRepository::validate($input, array_keys($input));
        if ($val->fails()) {
            return Redirect::route('account.profile')->withInput()->withErrors($val->errors());
        }

        $user = Credentials::getUser();
        $this->checkUser($user);

        $email = $user['email'];

        $user->update($input);

        if ($email !== $input['email']) {
            $mail = [
                'old'     => $email,
                'new'     => $input['email'],
                'url'     => URL::to(Config::get('credentials.home', '/')),
                'subject' => Config::get('app.name').' - New Email Information',
            ];

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['old'])->subject($mail['subject']);
            });

            Mail::queue('credentials::emails.newemail', $mail, function ($message) use ($mail) {
                $message->to($mail['new'])->subject($mail['subject']);
            });
        }

        return Redirect::route('account.profile')
            ->with('success', 'Your details have been updated successfully.');
    }
1038827
public function redirect() : ?RedirectResponse
    {
        if (!$this->enabled()) {
            return null;
        }

        return redirect()
            ->back()
            ->withErrors([
                'form-verify-error' => $this->redirectMessage,
            ])
            ->withInput();
    }
749955
public function actionResetPassword()
    {
        /** @var User $user */
        $user = null;
        
        while (empty($user)) {
            $email = $this->email ?: $this->prompt('User E-Mail:');
            $user = User::findByEmail($email);
            if (empty($user)) {
                $this->outputError('The provided E-Mail not found in the System.');
            }
        }
    
        $password = $this->password ?: $this->prompt('User Password:');
    
        if ($this->confirm("Are you sure to change the password of User '$email'?") !== true) {
            return $this->outputError('Abort password change process.');
        }
        
        $user->password_salt = Yii::$app->getSecurity()->generateRandomString();
        $user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
        if ($user->save(true, ['password', 'password_salt'])) {
            return $this->outputSuccess("The password for user ($email) has been changed.");
        }
    
        return $this->outputError("The password could not changed.\n" . implode("\n", $user->firstErrors));
    }
399371
public function required_password_upgrade()
    {
        $email = $this->post('uEmail');
        $token = $this->app->make(Token::class);
        $this->set('token', $token);

        if ($email) {
            $errorValidator = Core::make('helper/validation/error');
            $userInfo = Core::make('Concrete\Core\User\UserInfoRepository')->getByName(Session::get('uPasswordResetUserName'));

            try {
                if ($userInfo && $email != $userInfo->getUserEmail()) {
                    throw new \Exception(t(sprintf('Invalid email address %s provided resetting a password', $email)));
                }
            } catch (\Exception $e) {
                $errorValidator->add($e);
            }

            $this->forgot_password();
        } else {
            $this->set('authType', $this->getAuthenticationType());
            $this->set('intro_msg', Core::make('config/database')->get('concrete.password.reset.message'));
        }
    }
207056
public function postReminder() {
    $email = Input::get('email');

    try {
      $this->reminder->send($email);
      return Redirect::to("/user/recupero-success")->with(array ("messageReminder" => L::t('Check your mail inbox, we sent you an email to recover your password.')));
    } catch (Pbi $e) {
      $errors = $this->reminder->getErrors();
      return Redirect::back()->withErrors($errors);
    }
  }
275423
public function adminSendEmailAction()
    {
        $email = $this->container->get('request')->query->get('email');

        /**
         * @var $user UserInterface
         */
        $user = $this->container->get('fos_user.user_manager')->findUserByEmail($email);

        if (null === $user) {
            $this->setFlash(self::SESSION_ADMIN_RESET, 'ctp_user.user.actions.reset_password.not_exist');
        } else {
            $code = $this->resetEmail($user);

            switch ($code) {
                case self::RESET_EMAIL_ALREADY_SENT:
                    $this->setFlash(
                        self::SESSION_ADMIN_RESET,
                        'ctp_user.user.actions.reset_password.already_sent'
                    );
                    break;
                case self::RESET_EMAIL_OK:
                    $this->setFlash(
                        self::SESSION_ADMIN_RESET,
                        'ctp_user.user.actions.reset_password.sent'
                    );
                    break;
            }
        }

        return new RedirectResponse(
            $this->container->get('router')->generate('sam_user_list')
        );
    }
163012
public function skipAuthorization()
    {
        $request = $this->getController()->request;
        $service = $this->getService($request);

        $service->skipAuthorization();

        return $this;
    }
677533
public function updatePositionAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
            return $response;
        }

        try {
            $mode = $this->getRequest()->get('mode', null);

            if ($mode == 'up') {
                $mode = UpdatePositionEvent::POSITION_UP;
            } elseif ($mode == 'down') {
                $mode = UpdatePositionEvent::POSITION_DOWN;
            } else {
                $mode = UpdatePositionEvent::POSITION_ABSOLUTE;
            }

            $position = $this->getRequest()->get('position', null);

            $event = $this->createUpdatePositionEvent($mode, $position);

            $this->dispatch($this->changePositionEventIdentifier, $event);
        } catch (\Exception $ex) {
            // Any error
            return $this->errorPage($ex);
        }

        $response = $this->performAdditionalUpdatePositionAction($event);

        if ($response == null) {
            return $this->redirectToListTemplate();
        } else {
            return $response;
        }
    }
403529
public function changePasswordAction(Request $request)
    {
        $user = $this->getUser();
        if (!is_object($user) || !$user instanceof UserInterface) {
            throw new AccessDeniedException('This user does not have access to this section.');
        }

        /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
        $dispatcher = $this->get('event_dispatcher');

        $event = new GetResponseUserEvent($user, $request);
        $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_INITIALIZE, $event);

        if (null !== $event->getResponse()) {
            return $event->getResponse();
        }

        /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
        $formFactory = $this->get('fos_user.change_password.form.factory');

        $form = $formFactory->createForm();
        $form->setData($user);

        $form->handleRequest($request);

        if ($form->isValid()) {
            /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
            $userManager = $this->get('fos_user.user_manager');

            $event = new FormEvent($form, $request);
            $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_SUCCESS, $event);

            $userManager->updateUser($user);

            if (null === $response = $event->getResponse()) {
                $this->get('session')->getFlashBag()->add('message', array(
                    'type' => 'success',
                    'message' => 'The record has been updated successfully.',
                ));

                return new RedirectResponse($this->generateUrl('admin_user'));
            }

            $dispatcher->dispatch(FOSUserEvents::CHANGE_PASSWORD_COMPLETED, new FilterUserResponseEvent($user, $request, $response));

            return $response;
        }

        return $this->render('FOSUserBundle:ChangePassword:changePassword.html.twig', array(
            'form' => $form->createView()
        ));
    }
1187609
public function changePasswordAction()
    {
        if(!$user = $this->identity()) {
            return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
    
        $form = $this->getUserFormHelper()->createUserForm($user, 'ChangePassword');
        $message = null;
        if($this->getRequest()->isPost()) {
            $currentAnswer = $user->getAnswer();
            $form->setValidationGroup('password', 'newPasswordVerify', 'answer', 'csrf');
            $form->setData($this->getRequest()->getPost());
            if($form->isValid()) {
                $data = $form->getData();
                $identicalValidator = new IdenticalValidator(array('token' => $currentAnswer));
                if($identicalValidator->isValid($data->getAnswer())) {
                    $user->setPassword(UserCredentialsService::encryptPassword($this->params()->fromPost('password')));
                    $entityManager = $this->getEntityManager();
                    $entityManager->persist($user);
                    $entityManager->flush();
    
                    $viewModel = new ViewModel(array('navMenu' => $this->getOptions()->getNavMenu()));
                    $viewModel->setTemplate('csn-user/registration/change-password-success');
                    return $viewModel;
                } else {
                    $message = $this->getTranslatorHelper()->translate('Your answer is wrong. Please provide the correct answer.');
                }
            }
        }
    
        return new ViewModel(array('form' => $form, 'navMenu' => $this->getOptions()->getNavMenu(), 'message' => $message, 'question' => $user->getQuestion()->getQuestion()));
    }
974083
public function redirect() : RedirectResponse {
        if( ! $this->notified) {
            $this->notify();
        }

        $url = $this->url ?: app(UrlGenerator::class)->previous();

        return response()->redirectTo($url);
    }
162991
public function changePasswordUpdate(ChangePasswordRequest $request, User $user)
    {
        $password = $request->get('password');
        $user->update(['password' => bcrypt($password)]);
        Mail::to($user->email)->send(new ChangePasswordMail($user, $password));

        return redirect()->route('admin.user.index');
    }