ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLocalUserPasswordSettingsGUI Class Reference
+ Collaboration diagram for ilLocalUserPasswordSettingsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 showPassword (?Form $form=null, bool $hide_form=false, ?MessageBox $message_box=null)
 
 getPasswordForm (?ServerRequestInterface $request=null, array $errors=[])
 

Data Fields

const CMD_SHOW_PASSWORD = 'showPassword'
 
const CMD_SAVE_PASSWORD = 'savePassword'
 

Private Attributes

const NEW_PASSWORD = 'new_password'
 
const CURRENT_PASSWORD = 'current_password'
 
readonly ServerRequestInterface $request
 
readonly ilErrorHandling $error
 
readonly Refinery $refinery
 
readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilLanguage $lng
 
readonly ilObjUser $user
 
readonly ilCtrlInterface $ctrl
 
readonly LocalUserPasswordManager $password_manager
 

Detailed Description

Definition at line 31 of file class.ilLocalUserPasswordSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLocalUserPasswordSettingsGUI::__construct ( )

Definition at line 48 of file class.ilLocalUserPasswordSettingsGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

49  {
50  global $DIC;
51  $this->user = $DIC->user();
52  $this->ctrl = $DIC->ctrl();
53  $this->error = $DIC['ilErr'];
54  $this->lng = $DIC->language();
55  $this->refinery = $DIC->refinery();
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');
62  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilLocalUserPasswordSettingsGUI::executeCommand ( )

Definition at line 64 of file class.ilLocalUserPasswordSettingsGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

64  : void
65  {
66  $cmd = $this->ctrl->getCmd();
67  switch ($cmd) {
68  default:
69  if (method_exists($this, $cmd)) {
70  $this->$cmd();
71  } else {
72  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
73  }
74 
75  break;
76  }
77  }
+ Here is the call graph for this function:

◆ getPasswordForm()

ilLocalUserPasswordSettingsGUI::getPasswordForm ( ?ServerRequestInterface  $request = null,
array  $errors = [] 
)

Definition at line 106 of file class.ilLocalUserPasswordSettingsGUI.php.

References $data, $txt, $user, ilDAVActivationChecker\_isActive(), ilAuthUtils\AUTH_CAS, ilAuthUtils\AUTH_LOCAL, ilAuthUtils\AUTH_SHIBBOLETH, ILIAS\Repository\ctrl(), ilSession\get(), ilSecuritySettingsChecker\getPasswordRequirementsInfo(), ilSecuritySettingsChecker\isPassword(), ilSecuritySettingsChecker\isPasswordValidForUserContext(), ILIAS\Repository\lng(), null, ILIAS\Repository\refinery(), ilSession\set(), showPassword(), ILIAS\Data\Password\toString(), and ILIAS\Repository\user().

Referenced by showPassword().

109  : Form {
110  $items = [];
111  if ($this->password_manager->allowPasswordChange($this->user)) {
112  $pw_info_set = false;
113  if ((int) $this->user->getAuthMode(true) === ilAuthUtils::AUTH_LOCAL) {
114  $cpass = $this->ui_factory->input()->field()->password(
115  $this->lng->txt(self::CURRENT_PASSWORD),
117  );
118 
119  $pw_info_set = true;
120  if ($this->user->getPasswd()) {
121  $cpass = $cpass->withRequired(true);
122  }
123  $cpass = $cpass->withRevelation(true);
124  $cpass_error = $errors[self::CURRENT_PASSWORD] ?? [];
125  if ($cpass_error !== []) {
126  $cpass = $cpass->withError(implode('<br>', $cpass_error));
127  }
128  $cpass = $cpass->withAdditionalTransformation(
129  $this->refinery->custom()->constraint(function (Password $value): bool {
130  return
131  ((int) $this->user->getAuthMode(true) !== ilAuthUtils::AUTH_LOCAL) ||
132  LocalUserPasswordManager::getInstance()->verifyPassword(
133  $this->user,
134  $value->toString()
135  );
136  }, $this->lng->txt('passwd_wrong'))
137  );
138 
139  $items[self::CURRENT_PASSWORD] = $cpass;
140  }
141 
142  // new password
143  $ipass = $this->ui_factory->input()->field()->password(
144  $this->lng->txt('desired_password'),
145  );
146  if ($pw_info_set === false) {
147  $ipass = $ipass->withByline(ilSecuritySettingsChecker::getPasswordRequirementsInfo());
148  }
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));
154  }
155  $ipass = $ipass->withAdditionalTransformation(
156  $this->refinery->custom()->constraint(function (Password $value): bool {
157  return ilSecuritySettingsChecker::isPassword($value->toString(), $custom_error);
158  }, function (Closure $txt, Password $value): string {
159  $custom_error = '';
160  !ilSecuritySettingsChecker::isPassword($value->toString(), $custom_error);
161  if ($custom_error !== '' && $custom_error !== null) {
162  return $custom_error;
163  }
164 
165  return $this->lng->txt('passwd_invalid');
166  })
167  );
168  $ipass = $ipass->withAdditionalTransformation(
169  $this->refinery->custom()->constraint(
170  function (Password $value): bool {
172  $value->toString(),
173  $this->user,
174  $error_lng_var
175  );
176  },
177  function (Closure $cls, Password $value): string {
179  $value->toString(),
180  $this->user,
181  $error_lng_var
182  );
183 
184  return $this->lng->txt($error_lng_var ?? '');
185  }
186  )
187  );
188  $items[self::NEW_PASSWORD] = $ipass;
189 
190  switch ($this->user->getAuthMode(true)) {
192  $title = $this->lng->txt('chg_password');
193 
194  break;
198  $title = $this->lng->txt('chg_ilias_and_webfolder_password');
199  } else {
200  $title = $this->lng->txt('chg_ilias_password');
201  }
202 
203  break;
204  default:
205  $title = $this->lng->txt('chg_ilias_password');
206 
207  break;
208  }
209  $section = $this->ui_factory->input()->field()->section($items, $title);
210  $items = ['password' => $section];
211  }
212 
213  return $this->ui_factory->input()->container()->form()->standard(
214  $this->ctrl->getLinkTarget($this, 'savePassword'),
215  $items
216  )->withSubmitLabel($this->lng->txt('save'));
217  }
static isPassword(string $a_passwd, ?string &$customError=null)
A password is used as part of credentials for authentication.
Definition: Password.php:30
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
$txt
Definition: error.php:31
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showPassword()

ilLocalUserPasswordSettingsGUI::showPassword ( ?Form  $form = null,
bool  $hide_form = false,
?MessageBox  $message_box = null 
)

Definition at line 79 of file class.ilLocalUserPasswordSettingsGUI.php.

References getPasswordForm(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by getPasswordForm().

83  : void {
84  // check whether password of user have to be changed
85  // due to first login or password of user is expired
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')
90  );
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));
95  }
96 
97  if (!$form && !$hide_form) {
98  $form = $this->getPasswordForm();
99  }
100  $this->tpl->setContent(
101  !$hide_form ? $this->ui_renderer->render($form) : $this->ui_renderer->render($message_box)
102  );
103  $this->tpl->printToStdout();
104  }
getPasswordForm(?ServerRequestInterface $request=null, array $errors=[])
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

readonly ilCtrlInterface ilLocalUserPasswordSettingsGUI::$ctrl
private

Definition at line 45 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $error

readonly ilErrorHandling ilLocalUserPasswordSettingsGUI::$error
private

Definition at line 38 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $lng

readonly ilLanguage ilLocalUserPasswordSettingsGUI::$lng
private

Definition at line 43 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $password_manager

readonly LocalUserPasswordManager ilLocalUserPasswordSettingsGUI::$password_manager
private

Definition at line 46 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $refinery

readonly Refinery ilLocalUserPasswordSettingsGUI::$refinery
private

Definition at line 39 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $request

readonly ServerRequestInterface ilLocalUserPasswordSettingsGUI::$request
private

Definition at line 37 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ilLocalUserPasswordSettingsGUI::$tpl
private

Definition at line 42 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $ui_factory

readonly UIFactory ilLocalUserPasswordSettingsGUI::$ui_factory
private

Definition at line 40 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $ui_renderer

readonly UIRenderer ilLocalUserPasswordSettingsGUI::$ui_renderer
private

Definition at line 41 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ $user

readonly ilObjUser ilLocalUserPasswordSettingsGUI::$user
private

Definition at line 44 of file class.ilLocalUserPasswordSettingsGUI.php.

Referenced by getPasswordForm().

◆ CMD_SAVE_PASSWORD

const ilLocalUserPasswordSettingsGUI::CMD_SAVE_PASSWORD = 'savePassword'

◆ CMD_SHOW_PASSWORD

const ilLocalUserPasswordSettingsGUI::CMD_SHOW_PASSWORD = 'showPassword'

◆ CURRENT_PASSWORD

const ilLocalUserPasswordSettingsGUI::CURRENT_PASSWORD = 'current_password'
private

Definition at line 34 of file class.ilLocalUserPasswordSettingsGUI.php.

◆ NEW_PASSWORD

const ilLocalUserPasswordSettingsGUI::NEW_PASSWORD = 'new_password'
private

Definition at line 33 of file class.ilLocalUserPasswordSettingsGUI.php.


The documentation for this class was generated from the following file: