19 declare(strict_types=1);
    51         $this->
user = $DIC->user();
    52         $this->
ctrl = $DIC->ctrl();
    53         $this->error = $DIC[
'ilErr'];
    54         $this->
lng = $DIC->language();
    56         $this->tpl = $DIC->ui()->mainTemplate();
    57         $this->request = $DIC->http()->request();
    58         $this->ui_factory = $DIC->ui()->factory();
    59         $this->ui_renderer = $DIC->ui()->renderer();
    60         $this->password_manager = LocalUserPasswordManager::getInstance();
    61         $this->
lng->loadLanguageModule(
'user');
    66         $cmd = $this->
ctrl->getCmd();
    69                 if (method_exists($this, $cmd)) {
    72                     $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
    81         bool $hide_form = 
false,
    86         if ($this->
user->isPasswordChangeDemanded()) {
    87             $this->tpl->setOnScreenMessage(
    88                 $this->tpl::MESSAGE_TYPE_INFO,
    89                 $this->
lng->txt(
'password_change_on_first_login_demand')
    91         } elseif ($this->
user->isPasswordExpired()) {
    92             $msg = $this->
lng->txt(
'password_expired');
    93             $password_age = $this->
user->getPasswordAge();
    94             $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, sprintf($msg, $password_age));
    97         if (!$form && !$hide_form) {
   100         $this->tpl->setContent(
   101             !$hide_form ? $this->ui_renderer->render($form) : $this->ui_renderer->render($message_box)
   103         $this->tpl->printToStdout();
   111         if ($this->password_manager->allowPasswordChange($this->user)) {
   112             $pw_info_set = 
false;
   114                 $cpass = $this->ui_factory->input()->field()->password(
   115                     $this->
lng->txt(self::CURRENT_PASSWORD),
   120                 if ($this->
user->getPasswd()) {
   121                     $cpass = $cpass->withRequired(
true);
   123                 $cpass = $cpass->withRevelation(
true);
   124                 $cpass_error = $errors[self::CURRENT_PASSWORD] ?? [];
   125                 if ($cpass_error !== []) {
   126                     $cpass = $cpass->withError(implode(
'<br>', $cpass_error));
   128                 $cpass = $cpass->withAdditionalTransformation(
   132                             LocalUserPasswordManager::getInstance()->verifyPassword(
   136                     }, $this->
lng->txt(
'passwd_wrong'))
   139                 $items[self::CURRENT_PASSWORD] = $cpass;
   143             $ipass = $this->ui_factory->input()->field()->password(
   144                 $this->
lng->txt(
'desired_password'),
   146             if ($pw_info_set === 
false) {
   149             $ipass = $ipass->withRequired(
true);
   150             $ipass = $ipass->withRevelation(
true);
   151             $ipass_error = $errors[self::NEW_PASSWORD] ?? [];
   152             if ($ipass_error !== []) {
   153                 $ipass = $ipass->withError(implode(
'<br>', $ipass_error));
   155             $ipass = $ipass->withAdditionalTransformation(
   161                     if ($custom_error !== 
'' && $custom_error !== null) {
   162                         return $custom_error;
   165                     return $this->
lng->txt(
'passwd_invalid');
   168             $ipass = $ipass->withAdditionalTransformation(
   169                 $this->
refinery->custom()->constraint(
   184                         return $this->
lng->txt($error_lng_var ?? 
'');
   188             $items[self::NEW_PASSWORD] = $ipass;
   190             switch ($this->
user->getAuthMode(
true)) {
   192                     $title = $this->
lng->txt(
'chg_password');
   198                         $title = $this->
lng->txt(
'chg_ilias_and_webfolder_password');
   200                         $title = $this->
lng->txt(
'chg_ilias_password');
   205                     $title = $this->
lng->txt(
'chg_ilias_password');
   209             $section = $this->ui_factory->input()->field()->section($items, $title);
   210             $items = [
'password' => $section];
   213         return $this->ui_factory->input()->container()->form()->standard(
   214             $this->
ctrl->getLinkTarget($this, 
'savePassword'),
   216         )->withSubmitLabel($this->
lng->txt(
'save'));
   219     public function savePassword(): 
void   221         if (!$this->password_manager->allowPasswordChange($this->user)) {
   222             $this->
ctrl->redirect($this, 
'showPersonalData');
   228         $section = $form->getInputs()[
'password'];
   233         $cp = $section->getInputs()[self::CURRENT_PASSWORD] ?? null;
   234         $np = $section->getInputs()[self::NEW_PASSWORD];
   235         $errors = [self::CURRENT_PASSWORD => [], self::NEW_PASSWORD => []];
   237         if (!$form->getError()) {
   238             $data = $form->getData();
   240             if ($cp && $cp->getError()) {
   242                 $errors[self::CURRENT_PASSWORD][] = $cp->getError();
   244             if ($np->getError()) {
   246                 $errors[self::NEW_PASSWORD][] = $np->getError();
   249             $entered_current_password = $cp ? $cp->getValue() : 
'';
   250             $entered_new_password = $np->getValue();
   253                 $entered_current_password === $entered_new_password &&
   254                 ($this->
user->isPasswordExpired() || $this->
user->isPasswordChangeDemanded())
   257                 $errors[self::NEW_PASSWORD][] = $this->
lng->txt(
'new_pass_equals_old_pass');
   261                 $this->
user->resetPassword($entered_new_password, $entered_new_password);
   262                 if ($entered_current_password !== $entered_new_password) {
   263                     $this->
user->setLastPasswordChangeToNow();
   264                     $this->
user->setPasswordPolicyResetStatus(
false);
   265                     $this->
user->update();
   269                     $this->tpl->setOnScreenMessage(
   270                         $this->tpl::MESSAGE_TYPE_SUCCESS,
   271                         $this->
lng->txt(
'saved_successfully'),
   276                     $this->
ctrl->redirectToURL($target);
   281                         $this->ui_factory->messageBox()->success($this->
lng->txt(
'saved_successfully'))
 static get(string $a_var)
 
readonly UIRenderer $ui_renderer
 
static isPassword(string $a_passwd, ?string &$customError=null)
 
readonly ilGlobalTemplateInterface $tpl
 
A password is used as part of credentials for authentication. 
 
readonly Refinery $refinery
 
readonly LocalUserPasswordManager $password_manager
 
readonly UIFactory $ui_factory
 
getPasswordForm(ServerRequestInterface $request=null, array $errors=[])
 
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
 
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo() 
 
showPassword(Form $form=null, bool $hide_form=false, MessageBox $message_box=null)
 
readonly ServerRequestInterface $request
 
readonly ilErrorHandling $error
 
static set(string $a_var, $a_val)
Set a value. 
 
readonly ilCtrlInterface $ctrl