public function run()
	{
		/** @var Request $request */
		$request = System::getContainer()->get('request_stack')->getCurrentRequest();

		$objTemplate = new BackendTemplate('be_password');

		if (Input::post('FORM_SUBMIT') == 'tl_password')
		{
			$pw = $request->request->get('password');
			$cnf = $request->request->get('confirm');

			// The passwords do not match
			if ($pw != $cnf)
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
			}
			// Password too short
			elseif (Utf8::strlen($pw) < Config::get('minPasswordLength'))
			{
				Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], Config::get('minPasswordLength')));
			}
			// Password and username are the same
			elseif ($pw == $this->User->username)
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
			}
			// Save the data
			else
			{
				// Make sure the password has been changed
				if (password_verify($pw, $this->User->password))
				{
					Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
				}
				else
				{
					$this->loadDataContainer('tl_user');

					// Trigger the save_callback
					if (\is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback']))
					{
						$dc = new DC_Table('tl_user');
						$dc->id = $this->User->id;

						foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback)
						{
							if (\is_array($callback))
							{
								$this->import($callback[0]);
								$pw = $this->{$callback[0]}->{$callback[1]}($pw, $dc);
							}
							elseif (\is_callable($callback))
							{
								$pw = $callback($pw, $dc);
							}
						}
					}

					$objUser = UserModel::findByPk($this->User->id);
					$objUser->pwChange = '';
					$objUser->password = password_hash($pw, PASSWORD_DEFAULT);
					$objUser->save();

					Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
					$this->redirect('contao/main.php');
				}
			}

			$this->reload();
		}

		$objTemplate->theme = Backend::getTheme();
		$objTemplate->messages = Message::generate();
		$objTemplate->base = Environment::get('base');
		$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
		$objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
		$objTemplate->host = Environment::get('host');
		$objTemplate->charset = Config::get('characterSet');
		$objTemplate->action = ampersand(Environment::get('request'));
		$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_new'];
		$objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['pw_change'];
		$objTemplate->submitButton = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
		$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
		$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];

		return $objTemplate->getResponse();
	}
public function run()
	{
		
		$request = System::getContainer()->get('request_stack')->getCurrentRequest();

		$objTemplate = new BackendTemplate('be_password');

		if (Input::post('FORM_SUBMIT') == 'tl_password')
		{
			$pw = $request->request->get('password');
			$cnf = $request->request->get('confirm');

			
			if ($pw != $cnf)
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
			}
			
			elseif (Utf8::strlen($pw) < Config::get('minPasswordLength'))
			{
				Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], Config::get('minPasswordLength')));
			}
			
			elseif ($pw == $this->User->username)
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
			}
			
			else
			{
				
				if (password_verify($pw, $this->User->password))
				{
					Message::addError($GLOBALS['TL_LANG']['MSC']['pw_change']);
				}
				else
				{
					$this->loadDataContainer('tl_user');

					
					if (\is_array($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback']))
					{
						$dc = new DC_Table('tl_user');
						$dc->id = $this->User->id;

						foreach ($GLOBALS['TL_DCA']['tl_user']['fields']['password']['save_callback'] as $callback)
						{
							if (\is_array($callback))
							{
								$this->import($callback[0]);
								$pw = $this->{$callback[0]}->{$callback[1]}($pw, $dc);
							}
							elseif (\is_callable($callback))
							{
								$pw = $callback($pw, $dc);
							}
						}
					}

					$objUser = UserModel::findByPk($this->User->id);
					$objUser->pwChange = '';
					$objUser->password = password_hash($pw, PASSWORD_DEFAULT);
					$objUser->save();

					Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
					$this->redirect('contao/main.php');
				}
			}

			$this->reload();
		}

		$objTemplate->theme = Backend::getTheme();
		$objTemplate->messages = Message::generate();
		$objTemplate->base = Environment::get('base');
		$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
		$objTemplate->title = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['pw_new']);
		$objTemplate->host = Environment::get('host');
		$objTemplate->charset = Config::get('characterSet');
		$objTemplate->action = ampersand(Environment::get('request'));
		$objTemplate->headline = $GLOBALS['TL_LANG']['MSC']['pw_new'];
		$objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['pw_change'];
		$objTemplate->submitButton = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['continue']);
		$objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
		$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['confirm'][0];

		return $objTemplate->getResponse();
	}
public function run ( ) { /** @var Request $request */ $ request = System :: getContainer ( ) -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; $ objTemplate = new BackendTemplate ( 'be_password' ) ; if ( Input :: post ( 'FORM_SUBMIT' ) == 'tl_password' ) { $ pw = $ request -> request -> get ( 'password' ) ; $ cnf = $ request -> request -> get ( 'confirm' ) ; // The passwords do not match if ( $ pw != $ cnf ) { Message :: addError ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'passwordMatch' ] ) ; } // Password too short elseif ( Utf8 :: strlen ( $ pw ) < Config :: get ( 'minPasswordLength' ) ) { Message :: addError ( sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'passwordLength' ] , Config :: get ( 'minPasswordLength' ) ) ) ; } // Password and username are the same elseif ( $ pw == $ this -> User -> username ) { Message :: addError ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'passwordName' ] ) ; } // Save the data else { // Make sure the password has been changed if ( password_verify ( $ pw , $ this -> User -> password ) ) { Message :: addError ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'pw_change' ] ) ; } else { $ this -> loadDataContainer ( 'tl_user' ) ; // Trigger the save_callback if ( \ is_array ( $ GLOBALS [ 'TL_DCA' ] [ 'tl_user' ] [ 'fields' ] [ 'password' ] [ 'save_callback' ] ) ) { $ dc = new DC_Table ( 'tl_user' ) ; $ dc -> id = $ this -> User -> id ; foreach ( $ GLOBALS [ 'TL_DCA' ] [ 'tl_user' ] [ 'fields' ] [ 'password' ] [ 'save_callback' ] as $ callback ) { if ( \ is_array ( $ callback ) ) { $ this -> import ( $ callback [ 0 ] ) ; $ pw = $ this -> { $ callback [ 0 ] } -> { $ callback [ 1 ] } ( $ pw , $ dc ) ; } elseif ( \ is_callable ( $ callback ) ) { $ pw = $ callback ( $ pw , $ dc ) ; } } } $ objUser = UserModel :: findByPk ( $ this -> User -> id ) ; $ objUser -> pwChange = '' ; $ objUser -> password = password_hash ( $ pw , PASSWORD_DEFAULT ) ; $ objUser -> save ( ) ; Message :: addConfirmation ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'pw_changed' ] ) ; $ this -> redirect ( 'contao/main.php' ) ; } } $ this -> reload ( ) ; } $ objTemplate -> theme = Backend :: getTheme ( ) ; $ objTemplate -> messages = Message :: generate ( ) ; $ objTemplate -> base = Environment :: get ( 'base' ) ; $ objTemplate -> language = $ GLOBALS [ 'TL_LANGUAGE' ] ; $ objTemplate -> title = StringUtil :: specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'pw_new' ] ) ; $ objTemplate -> host = Environment :: get ( 'host' ) ; $ objTemplate -> charset = Config :: get ( 'characterSet' ) ; $ objTemplate -> action = ampersand ( Environment :: get ( 'request' ) ) ; $ objTemplate -> headline = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'pw_new' ] ; $ objTemplate -> explain = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'pw_change' ] ; $ objTemplate -> submitButton = StringUtil :: specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'continue' ] ) ; $ objTemplate -> password = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'password' ] [ 0 ] ; $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'confirm' ] [ 0 ] ; return $ objTemplate -> getResponse ( ) ; }
Run the controller and parse the password template

@return Response
Run the controller and parse the password template