ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPasswordAssistanceGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPasswordAssistanceGUI:
+ Collaboration diagram for ilPasswordAssistanceGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 showAssistanceForm (ilPropertyFormGUI $form=null)
 
 submitAssistanceForm ()
 Reads the submitted data from the password assistance form. More...
 
 showAssignPasswordForm (ilPropertyFormGUI $form=null, string $pwassist_id='')
 Assign password form. More...
 
 submitAssignPasswordForm ()
 Reads the submitted data from the password assistance form. More...
 
 showUsernameAssistanceForm (ilPropertyFormGUI $form=null)
 Shows the password assistance form. More...
 
 submitUsernameAssistanceForm ()
 Reads the submitted data from the password assistance form. More...
 
 showMessageForm (string $text, string $permanent_link_context)
 This form is used to show a message to the user. More...
 

Protected Member Functions

 getClientId ()
 as replacement for "this->ilias" More...
 
 getBaseUrl ()
 Returns the ILIAS http path without a trailing /. More...
 
 buildUrl (string $script, array $queryParameters)
 
 getAssistanceForm ()
 
 getAssignPasswordForm (string $pwassist_id)
 
 getUsernameAssistanceForm ()
 
 fillPermanentLink (string $context)
 

Protected Attributes

ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilRbacReview $rbacreview
 
ilGlobalTemplateInterface $tpl
 
ilSetting $settings
 
ilErrorHandling $ilErr
 
RefineryFactory $refinery
 
HTTPServices $http
 
ilHelpGUI $help
 
ilObjUser $actor
 

Private Member Functions

 retrieveRequestedKey ()
 

Private Attributes

const PERMANENT_LINK_TARGET_PW = 'pwassist'
 
const PERMANENT_LINK_TARGET_NAME = 'nameassist'
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Password assistance facility for users who have forgotten their password or for users for whom no password has been assigned yet.

Author
Werner Randelshofer wrand.nosp@m.els@.nosp@m.hsw.f.nosp@m.hz.c.nosp@m.h
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 29 of file class.ilPasswordAssistanceGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilPasswordAssistanceGUI::__construct ( )

Definition at line 47 of file class.ilPasswordAssistanceGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

48  {
49  global $DIC;
50 
51  $this->ctrl = $DIC->ctrl();
52  $this->lng = $DIC->language();
53  $this->rbacreview = $DIC->rbac()->review();
54  $this->tpl = $DIC->ui()->mainTemplate();
55  $this->settings = $DIC->settings();
56  $this->ilErr = $DIC['ilErr'];
57  $this->help = $DIC->help();
58  $this->http = $DIC->http();
59  $this->actor = $DIC->user();
60  $this->refinery = $DIC->refinery();
61  $this->ui_factory = $DIC->ui()->factory();
62  $this->ui_renderer = $DIC->ui()->renderer();
63 
64  $this->help->setScreenIdComponent('init');
65  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ buildUrl()

ilPasswordAssistanceGUI::buildUrl ( string  $script,
array  $queryParameters 
)
protected
Parameters
string$script
array$queryParameters
Returns
string

Definition at line 150 of file class.ilPasswordAssistanceGUI.php.

References $url, ilUtil\appendUrlParameterString(), and getBaseUrl().

Referenced by submitAssistanceForm(), and submitUsernameAssistanceForm().

150  : string
151  {
152  $url = implode('/', [
153  $this->getBaseUrl(),
154  ltrim($script, '/')
155  ]);
156 
158  $url,
159  http_build_query($queryParameters, null, '&')
160  );
161 
162  return $url;
163  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
$url
getBaseUrl()
Returns the ILIAS http path without a trailing /.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPasswordAssistanceGUI::executeCommand ( )

Definition at line 93 of file class.ilPasswordAssistanceGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), retrieveRequestedKey(), ILIAS\Repository\settings(), showAssignPasswordForm(), and showAssistanceForm().

94  {
95  if (!$this->settings->get('setup_ok')) {
96  $this->ilErr->raiseError('Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
97  }
98 
99  if (!$this->settings->get('password_assistance')) {
100  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
101  }
102 
103  if ($this->actor->getId() > 0 && !$this->actor->isAnonymous()) {
104  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
105  }
106 
107  $this->lng->loadLanguageModule('pwassist');
108  $cmd = $this->ctrl->getCmd() ?? '';
109  $next_class = $this->ctrl->getNextClass($this);
110 
111  switch ($next_class) {
112  default:
113  if ($cmd !== '' && method_exists($this, $cmd)) {
114  $this->$cmd();
115  return;
116  }
117 
118  if ($this->retrieveRequestedKey() !== '') {
119  $this->showAssignPasswordForm(null, $this->retrieveRequestedKey());
120  } else {
121  $this->showAssistanceForm();
122  }
123  break;
124  }
125  }
showAssignPasswordForm(ilPropertyFormGUI $form=null, string $pwassist_id='')
Assign password form.
showAssistanceForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ fillPermanentLink()

ilPasswordAssistanceGUI::fillPermanentLink ( string  $context)
protected

Definition at line 756 of file class.ilPasswordAssistanceGUI.php.

Referenced by showAssignPasswordForm(), showAssistanceForm(), showMessageForm(), and showUsernameAssistanceForm().

756  : void
757  {
758  $this->tpl->setPermanentLink('usr', null, $context);
759  }
$context
Definition: webdav.php:29
+ Here is the caller graph for this function:

◆ getAssignPasswordForm()

ilPasswordAssistanceGUI::getAssignPasswordForm ( string  $pwassist_id)
protected

Definition at line 394 of file class.ilPasswordAssistanceGUI.php.

References ILIAS\LTI\ToolProvider\$key, ILIAS\Repository\ctrl(), ilSecuritySettingsChecker\getPasswordRequirementsInfo(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

Referenced by showAssignPasswordForm(), and submitAssignPasswordForm().

395  {
396  $form = new ilPropertyFormGUI();
397  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssignPasswordForm'));
398  $form->setTarget('_parent');
399 
400  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
401  $username->setRequired(true);
402  $form->addItem($username);
403 
404  $password = new ilPasswordInputGUI($this->lng->txt('password'), 'password');
406  $password->setRequired(true);
407  $password->setUseStripSlashes(false);
408  $form->addItem($password);
409 
410  $key = new ilHiddenInputGUI('key');
411  $key->setValue($pwassist_id);
412  $form->addItem($key);
413  $form->addCommandButton('submitAssignPasswordForm', $this->lng->txt('submit'));
414  return $form;
415  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssistanceForm()

ilPasswordAssistanceGUI::getAssistanceForm ( )
protected

Definition at line 165 of file class.ilPasswordAssistanceGUI.php.

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

Referenced by showAssistanceForm(), and submitAssistanceForm().

166  {
167  $form = new ilPropertyFormGUI();
168 
169  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssistanceForm'));
170  $form->setTarget('_parent');
171 
172  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
173  $username->setRequired(true);
174  $form->addItem($username);
175 
176  $email = new ilEMailInputGUI($this->lng->txt('email'), 'email');
177  $email->setRequired(true);
178  $form->addItem($email);
179 
180  $form->addCommandButton('submitAssistanceForm', $this->lng->txt('submit'));
181  return $form;
182  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:302
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseUrl()

ilPasswordAssistanceGUI::getBaseUrl ( )
protected

Returns the ILIAS http path without a trailing /.

Definition at line 140 of file class.ilPasswordAssistanceGUI.php.

Referenced by buildUrl(), submitAssistanceForm(), and submitUsernameAssistanceForm().

140  : string
141  {
142  return rtrim(ILIAS_HTTP_PATH, '/');
143  }
+ Here is the caller graph for this function:

◆ getClientId()

ilPasswordAssistanceGUI::getClientId ( )
protected

as replacement for "this->ilias"

Definition at line 88 of file class.ilPasswordAssistanceGUI.php.

References CLIENT_ID.

Referenced by submitAssistanceForm(), and submitUsernameAssistanceForm().

88  : string
89  {
90  return CLIENT_ID;
91  }
const CLIENT_ID
Definition: constants.php:41
+ Here is the caller graph for this function:

◆ getSafePostCommands()

ilPasswordAssistanceGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 132 of file class.ilPasswordAssistanceGUI.php.

132  : array
133  {
134  return ['submitAssignPasswordForm'];
135  }

◆ getUnsafeGetCommands()

ilPasswordAssistanceGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 127 of file class.ilPasswordAssistanceGUI.php.

127  : array
128  {
129  return [];
130  }

◆ getUsernameAssistanceForm()

ilPasswordAssistanceGUI::getUsernameAssistanceForm ( )
protected

Definition at line 581 of file class.ilPasswordAssistanceGUI.php.

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

Referenced by showUsernameAssistanceForm(), and submitUsernameAssistanceForm().

582  {
583  $form = new ilPropertyFormGUI();
584 
585  $form->setFormAction($this->ctrl->getFormAction($this, 'submitUsernameAssistanceForm'));
586  $form->setTarget('_parent');
587 
588  $email = new ilTextInputGUI($this->lng->txt('email'), 'email');
589  $email->setRequired(true);
590  $form->addItem($email);
591 
592  $form->addCommandButton('submitUsernameAssistanceForm', $this->lng->txt('submit'));
593  return $form;
594  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:302
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveRequestedKey()

ilPasswordAssistanceGUI::retrieveRequestedKey ( )
private

Definition at line 67 of file class.ilPasswordAssistanceGUI.php.

References ILIAS\LTI\ToolProvider\$key, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by executeCommand().

67  : string
68  {
69  $key = $this->http->wrapper()->query()->retrieve(
70  'key',
71  $this->refinery->byTrying([
72  $this->refinery->kindlyTo()->string(),
73  $this->refinery->always(
74  $this->http->wrapper()->post()->retrieve(
75  'key',
76  $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
77  )
78  )
79  ])
80  );
81 
82  return $key;
83  }
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssignPasswordForm()

ilPasswordAssistanceGUI::showAssignPasswordForm ( ilPropertyFormGUI  $form = null,
string  $pwassist_id = '' 
)

Assign password form.

This form is used to assign a password to a username. To use this form, the following data must be provided as HTTP GET parameter, or in argument pwassist_id: key The key is used to retrieve the password assistance session. If the key is missing, or if the password assistance session has expired, the password assistance form will be shown instead of this form.

Definition at line 427 of file class.ilPasswordAssistanceGUI.php.

References db_pwassist_session_read(), fillPermanentLink(), getAssignPasswordForm(), ilUtil\getImagePath(), ILIAS\Repository\help(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilStartUpGUI\printToGlobalTemplate(), ILIAS\Repository\refinery(), ilGlobalTemplateInterface\setVariable(), and showAssistanceForm().

Referenced by executeCommand(), and submitAssignPasswordForm().

427  : void
428  {
429  $this->help->setSubScreenId('password_input');
430 
431  // Retrieve form data
432  if (!$pwassist_id) {
433  if ($this->http->wrapper()->query()->has('key')) {
434  $pwassist_id = $this->http->wrapper()->query()->retrieve(
435  'key',
436  $this->refinery->kindlyTo()->string()
437  );
438  }
439  }
440 
441  // Retrieve the session, and check if it is valid
442  require_once 'include/inc.pwassist_session_handler.php';
443  $pwassist_session = db_pwassist_session_read($pwassist_id);
444  if (
445  !is_array($pwassist_session) ||
446  count($pwassist_session) == 0 ||
447  $pwassist_session['expires'] < time()
448  ) {
449  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('pwassist_session_expired'));
450  $this->showAssistanceForm(null);
451  } else {
452  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assignpassword.html', true);
453  $tpl->setVariable(
454  'IMG_PAGEHEADLINE',
455  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
456  ilUtil::getImagePath('icon_auth.svg'),
457  $this->lng->txt('password_assistance')
458  ))
459  );
460  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
461 
462  $tpl->setVariable(
463  'TXT_ENTER_USERNAME_AND_NEW_PASSWORD',
464  $this->lng->txt('pwassist_enter_username_and_new_password')
465  );
466 
467  if (!$form) {
468  $form = $this->getAssignPasswordForm($pwassist_id);
469  }
470  $tpl->setVariable('FORM', $form->getHTML());
471  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
473  }
474  }
db_pwassist_session_read($pwassist_id)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static printToGlobalTemplate($tpl)
static http()
Fetches the global http state from ILIAS.
showAssistanceForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssistanceForm()

ilPasswordAssistanceGUI::showAssistanceForm ( ilPropertyFormGUI  $form = null)

Definition at line 184 of file class.ilPasswordAssistanceGUI.php.

References fillPermanentLink(), getAssistanceForm(), ilUtil\getImagePath(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\prepareFormOutput(), ilStartUpGUI\printToGlobalTemplate(), ILIAS\Repository\settings(), and ilGlobalTemplateInterface\setVariable().

Referenced by executeCommand(), showAssignPasswordForm(), submitAssignPasswordForm(), and submitAssistanceForm().

184  : void
185  {
186  $this->help->setSubScreenId('password_assistance');
187 
188  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assistance.html', true);
189  $tpl->setVariable(
190  'IMG_PAGEHEADLINE',
191  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
192  ilUtil::getImagePath('icon_auth.svg'),
193  $this->lng->txt('password_assistance')
194  ))
195  );
196  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
197 
198  $tpl->setVariable(
199  'TXT_ENTER_USERNAME_AND_EMAIL',
200  str_replace(
201  "\\n",
202  '<br />',
203  sprintf(
204  $this->lng->txt('pwassist_enter_username_and_email'),
205  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
206  $this->settings->get('admin_email')
207  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
208  )
209  )
210  );
211 
212  if (!$form) {
213  $form = $this->getAssistanceForm();
214  }
215  $tpl->setVariable('FORM', $form->getHTML());
216  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
218  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static prepareFormOutput($a_str, bool $a_strip=false)
static printToGlobalTemplate($tpl)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMessageForm()

ilPasswordAssistanceGUI::showMessageForm ( string  $text,
string  $permanent_link_context 
)

This form is used to show a message to the user.

Definition at line 739 of file class.ilPasswordAssistanceGUI.php.

References fillPermanentLink(), ilUtil\getImagePath(), ILIAS\Repository\lng(), ilStartUpGUI\printToGlobalTemplate(), and ilGlobalTemplateInterface\setVariable().

Referenced by submitAssignPasswordForm(), submitAssistanceForm(), and submitUsernameAssistanceForm().

739  : void
740  {
741  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
742  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
743  $tpl->setVariable(
744  'IMG_PAGEHEADLINE',
745  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
746  ilUtil::getImagePath('icon_auth.svg'),
747  $this->lng->txt('password_assistance')
748  ))
749  );
750 
751  $tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
752  $this->fillPermanentLink($permanent_link_context);
754  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static printToGlobalTemplate($tpl)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showUsernameAssistanceForm()

ilPasswordAssistanceGUI::showUsernameAssistanceForm ( ilPropertyFormGUI  $form = null)

Shows the password assistance form.

This form is used to request a password assistance mail from ILIAS. This form contains the following fields: username email When the user submits the form, then this script is invoked with the cmd 'submitAssistanceForm'.

Definition at line 605 of file class.ilPasswordAssistanceGUI.php.

References fillPermanentLink(), ilUtil\getImagePath(), getUsernameAssistanceForm(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\prepareFormOutput(), ilStartUpGUI\printToGlobalTemplate(), ILIAS\Repository\settings(), and ilGlobalTemplateInterface\setVariable().

Referenced by submitUsernameAssistanceForm().

605  : void
606  {
607  $this->help->setSubScreenId('username_assistance');
608 
609  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_username_assistance.html', true);
610  $tpl->setVariable(
611  'IMG_PAGEHEADLINE',
612  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
613  ilUtil::getImagePath('icon_auth.svg'),
614  $this->lng->txt('password_assistance')
615  ))
616  );
617  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
618 
619  $tpl->setVariable(
620  'TXT_ENTER_USERNAME_AND_EMAIL',
621  str_replace(
622  "\\n",
623  '<br />',
624  sprintf(
625  $this->lng->txt('pwassist_enter_email'),
626  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
627  $this->settings->get('admin_email')
628  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
629  )
630  )
631  );
632 
633  if (!$form) {
634  $form = $this->getUsernameAssistanceForm();
635  }
636  $tpl->setVariable('FORM', $form->getHTML());
637  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_NAME);
639  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static prepareFormOutput($a_str, bool $a_strip=false)
static printToGlobalTemplate($tpl)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submitAssignPasswordForm()

ilPasswordAssistanceGUI::submitAssignPasswordForm ( )

Reads the submitted data from the password assistance form.

The following form fields are read as HTTP POST parameters: key username password1 password2 The key is used to retrieve the password assistance session. If the key is missing, or if the password assistance session has expired, the password assistance form will be shown instead of this form. If the password assistance session is valid, and if the username matches the username, for which the password assistance has been requested, and if the new password is valid, ILIAS assigns the password to the user. Note: To prevent replay attacks, the session is deleted when the password has been assigned successfully.

Definition at line 492 of file class.ilPasswordAssistanceGUI.php.

References $message, db_pwassist_session_destroy(), db_pwassist_session_read(), getAssignPasswordForm(), ilObjectFactory\getInstanceByObjId(), ilObjUser\getLogin(), ilSecuritySettingsChecker\isPasswordValidForUserContext(), ILIAS\Repository\lng(), ilObjUser\resetPassword(), ilObjUser\setLastPasswordChangeToNow(), showAssignPasswordForm(), showAssistanceForm(), showMessageForm(), ilUtil\stripSlashes(), and ilObjUser\update().

492  : void
493  {
494  require_once 'include/inc.pwassist_session_handler.php';
495 
496  // We need to fetch this before form instantiation
497  $pwassist_id = ilUtil::stripSlashes($_POST['key']);
498 
499  $form = $this->getAssignPasswordForm($pwassist_id);
500  if (!$form->checkInput()) {
501  $form->setValuesByPost();
502  $this->showAssignPasswordForm($form, $pwassist_id);
503  return;
504  }
505 
506  $username = trim($form->getInput('username'));
507  $password = trim($form->getInput('password'));
508  $pwassist_id = $form->getInput('key');
509 
510  // Retrieve the session
511  $pwassist_session = db_pwassist_session_read($pwassist_id);
512 
513  if (
514  !is_array($pwassist_session) ||
515  count($pwassist_session) == 0 ||
516  $pwassist_session['expires'] < time()
517  ) {
518  $this->tpl->setOnScreenMessage('failure', str_replace("\\n", '', $this->lng->txt('pwassist_session_expired')));
519  $form->setValuesByPost();
520  $this->showAssistanceForm($form);
521  return;
522  } else {
523  $is_successful = true;
524  $message = '';
525 
526  $userObj = \ilObjectFactory::getInstanceByObjId($pwassist_session['user_id'], false);
527  if (!$userObj || !($userObj instanceof \ilObjUser)) {
528  $message = $this->lng->txt('user_does_not_exist');
529  $is_successful = false;
530  }
531 
532  // check if the username entered by the user matches the
533  // one of the user object.
534  if ($is_successful && strcasecmp($userObj->getLogin(), $username) != 0) {
535  $message = $this->lng->txt('pwassist_login_not_match');
536  $is_successful = false;
537  }
538 
539  $error_lng_var = '';
540  if (!ilSecuritySettingsChecker::isPasswordValidForUserContext($password, $userObj, $error_lng_var)) {
541  $message = $this->lng->txt($error_lng_var);
542  $is_successful = false;
543  }
544 
545  // End of validation
546  // If the validation was successful, we change the password of the
547  // user.
548  // ------------------
549  if ($is_successful) {
550  $is_successful = $userObj->resetPassword($password, $password);
551  if (!$is_successful) {
552  $message = $this->lng->txt('passwd_invalid');
553  }
554  }
555 
556  // If we are successful so far, we update the user object.
557  // ------------------
558  if ($is_successful) {
559  $userObj->setLastPasswordChangeToNow();
560  $userObj->update();
561  }
562 
563  // If we are successful, we destroy the password assistance
564  // session and redirect to the login page.
565  // Else we display the form again along with an error message.
566  // ------------------
567  if ($is_successful) {
568  db_pwassist_session_destroy($pwassist_id);
569  $this->showMessageForm(
570  sprintf($this->lng->txt('pwassist_password_assigned'), $username),
571  self::PERMANENT_LINK_TARGET_PW
572  );
573  } else {
574  $this->tpl->setOnScreenMessage('failure', str_replace("\\n", '', $message));
575  $form->setValuesByPost();
576  $this->showAssignPasswordForm($form, $pwassist_id);
577  }
578  }
579  }
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_read($pwassist_id)
showAssignPasswordForm(ilPropertyFormGUI $form=null, string $pwassist_id='')
Assign password form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
showMessageForm(string $text, string $permanent_link_context)
This form is used to show a message to the user.
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
showAssistanceForm(ilPropertyFormGUI $form=null)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:

◆ submitAssistanceForm()

ilPasswordAssistanceGUI::submitAssistanceForm ( )

Reads the submitted data from the password assistance form.

The following form fields are read as HTTP POST parameters: username email If the submitted username and email address matches an entry in the user data table, then ILIAS creates a password assistance session for the user, and sends a password assistance mail to the email address. For details about the creation of the session and the e-mail see function sendPasswordAssistanceMail().

Definition at line 231 of file class.ilPasswordAssistanceGUI.php.

References $_SERVER, $DIC, $email, $GLOBALS, ANONYMOUS_ROLE_ID, ilAuthUtils\AUTH_LOCAL, ilAuthUtils\AUTH_SAML, buildUrl(), db_pwassist_create_id(), db_pwassist_session_write(), getAssistanceForm(), getBaseUrl(), getClientId(), ilObjUser\getEmail(), ilObject\getId(), ilLoggerFactory\getLogger(), ilObjUser\getLogin(), ilObjUser\getUserIdByLogin(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ilAuthUtils\isLocalPasswordEnabledForAuthMode(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), showAssistanceForm(), showMessageForm(), and SYSTEM_ROLE_ID.

231  : void
232  {
233  $form = $this->getAssistanceForm();
234  if (!$form->checkInput()) {
235  $form->setValuesByPost();
236  $this->showAssistanceForm($form);
237  return;
238  }
239 
240  $defaultAuth = ilAuthUtils::AUTH_LOCAL;
241  if ($GLOBALS['DIC']['ilSetting']->get('auth_mode')) {
242  $defaultAuth = $GLOBALS['DIC']['ilSetting']->get('auth_mode');
243  }
244 
245  $assistance_callback = function () use ($form, $defaultAuth): void {
246  $username = trim($form->getInput('username'));
247  $email = trim($form->getInput('email'));
248 
249  $usrId = \ilObjUser::getUserIdByLogin($username);
250  if (!is_numeric($usrId) || !($usrId > 0)) {
251  \ilLoggerFactory::getLogger('usr')->info(
252  sprintf(
253  'Could not process password assistance form (reason: no user found) %s / %s',
254  $username,
255  $email
256  )
257  );
258 
259  return;
260  }
261 
262  $user = new \ilObjUser($usrId);
263  $emailAddresses = array_map('strtolower', [$user->getEmail(), $user->getSecondEmail()]);
264 
265  if (!in_array(strtolower($email), $emailAddresses)) {
266  if (0 === strlen(implode('', $emailAddresses))) {
267  \ilLoggerFactory::getLogger('usr')->info(sprintf(
268  'Could not process password assistance form (reason: account without email addresses): %s / %s',
269  $username,
270  $email
271  ));
272  } else {
273  \ilLoggerFactory::getLogger('usr')->info(sprintf(
274  'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
275  $username,
276  $email
277  ));
278  }
279  } elseif (
280  (
281  $user->getAuthMode(true) != ilAuthUtils::AUTH_LOCAL ||
282  ($user->getAuthMode(true) == $defaultAuth && $defaultAuth != ilAuthUtils::AUTH_LOCAL)
283  ) && !(
284  (int) $user->getAuthMode(true) === ilAuthUtils::AUTH_SAML &&
285  \ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))
286  )
287  ) {
288  \ilLoggerFactory::getLogger('usr')->info(sprintf(
289  'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
290  $username,
291  $email
292  ));
293  } elseif (
294  $this->rbacreview->isAssigned($user->getId(), ANONYMOUS_ROLE_ID) ||
295  $this->rbacreview->isAssigned($user->getId(), SYSTEM_ROLE_ID)
296  ) {
297  \ilLoggerFactory::getLogger('usr')->info(sprintf(
298  'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
299  $username,
300  $email
301  ));
302  } else {
303  $this->sendPasswordAssistanceMail($user);
304  }
305  };
306 
307  if (null !== ($assistance_duration = $this->settings->get("account_assistance_duration"))) {
308  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
309  $status = $duration->stretch($assistance_callback);
310  } else {
311  $status = $assistance_callback();
312  }
313 
314  $this->showMessageForm(
315  sprintf($this->lng->txt('pwassist_mail_sent'), $form->getInput('email')),
316  self::PERMANENT_LINK_TARGET_PW
317  );
318  }
static getLogger(string $a_component_id)
Get component logger.
const SYSTEM_ROLE_ID
Definition: constants.php:29
static getUserIdByLogin(string $a_login)
static http()
Fetches the global http state from ILIAS.
showMessageForm(string $text, string $permanent_link_context)
This form is used to show a message to the user.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:302
showAssistanceForm(ilPropertyFormGUI $form=null)
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
+ Here is the call graph for this function:

◆ submitUsernameAssistanceForm()

ilPasswordAssistanceGUI::submitUsernameAssistanceForm ( )

Reads the submitted data from the password assistance form.

The following form fields are read as HTTP POST parameters: username email If the submitted username and email address matches an entry in the user data table, then ILIAS creates a password assistance session for the user, and sends a password assistance mail to the email address. For details about the creation of the session and the e-mail see function sendPasswordAssistanceMail().

Definition at line 652 of file class.ilPasswordAssistanceGUI.php.

References $_SERVER, $DIC, $email, buildUrl(), getBaseUrl(), getClientId(), ilLoggerFactory\getLogger(), ilObjUser\getUserLoginsByEmail(), getUsernameAssistanceForm(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\settings(), showMessageForm(), and showUsernameAssistanceForm().

652  : void
653  {
654  $form = $this->getUsernameAssistanceForm();
655  if (!$form->checkInput()) {
656  $form->setValuesByPost();
657  $this->showUsernameAssistanceForm($form);
658 
659  return;
660  }
661 
662  $assistance_callback = function () use ($form): void {
663  $email = trim($form->getInput('email'));
665 
666  if (is_array($logins) && count($logins) > 0) {
667  $this->sendUsernameAssistanceMail($email, $logins);
668  } else {
669  \ilLoggerFactory::getLogger('usr')->info(sprintf(
670  'Could not sent username assistance emails to (reason: no user found): %s',
671  $email
672  ));
673  }
674  };
675 
676  if (null !== ($assistance_duration = $this->settings->get("account_assistance_duration"))) {
677  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
678  $status = $duration->stretch($assistance_callback);
679  } else {
680  $status = $assistance_callback();
681  }
682 
683  $this->showMessageForm($this->lng->txt('pwassist_mail_sent_generic'), self::PERMANENT_LINK_TARGET_NAME);
684  }
static getLogger(string $a_component_id)
Get component logger.
static http()
Fetches the global http state from ILIAS.
static getUserLoginsByEmail(string $a_email)
showMessageForm(string $text, string $permanent_link_context)
This form is used to show a message to the user.
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:302
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
+ Here is the call graph for this function:

Field Documentation

◆ $actor

ilObjUser ilPasswordAssistanceGUI::$actor
protected

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

◆ $ctrl

ilCtrlInterface ilPasswordAssistanceGUI::$ctrl
protected

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

◆ $help

ilHelpGUI ilPasswordAssistanceGUI::$help
protected

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

◆ $http

HTTPServices ilPasswordAssistanceGUI::$http
protected

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

◆ $ilErr

ilErrorHandling ilPasswordAssistanceGUI::$ilErr
protected

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

◆ $lng

ilLanguage ilPasswordAssistanceGUI::$lng
protected

Definition at line 35 of file class.ilPasswordAssistanceGUI.php.

◆ $rbacreview

ilRbacReview ilPasswordAssistanceGUI::$rbacreview
protected

Definition at line 36 of file class.ilPasswordAssistanceGUI.php.

◆ $refinery

RefineryFactory ilPasswordAssistanceGUI::$refinery
protected

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

◆ $settings

ilSetting ilPasswordAssistanceGUI::$settings
protected

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

◆ $tpl

ilGlobalTemplateInterface ilPasswordAssistanceGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilPasswordAssistanceGUI::$ui_factory
private

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

◆ $ui_renderer

ILIAS UI Renderer ilPasswordAssistanceGUI::$ui_renderer
private

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

◆ PERMANENT_LINK_TARGET_NAME

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_NAME = 'nameassist'
private

Definition at line 32 of file class.ilPasswordAssistanceGUI.php.

◆ PERMANENT_LINK_TARGET_PW

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_PW = 'pwassist'
private

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


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