ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPasswordAssistanceGUI Class Reference

Password assistance facility for users who have forgotten their password or for users for whom no password has been assigned yet. More...

+ Collaboration diagram for ilPasswordAssistanceGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 showAssistanceForm (ilPropertyFormGUI $form=null)
 
 submitAssistanceForm ()
 Reads the submitted data from the password assistance form. More...
 
 showAssignPasswordForm (ilPropertyFormGUI $form=null, $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 ($text)
 This form is used to show a message to the user. More...
 

Data Fields

const PERMANENT_LINK_TARGET_PW = 'pwassist'
 
const PERMANENT_LINK_TARGET_NAME = 'nameassist'
 

Protected Member Functions

 getBaseUrl ()
 Returns the ILIAS http path without a trailing /. More...
 
 buildUrl (string $script, array $queryParameters)
 
 getAssistanceForm ()
 
 getAssignPasswordForm ($pwassist_id)
 
 getUsernameAssistanceForm ()
 
 fillPermanentLink ($context)
 

Protected Attributes

 $ctrl
 
 $lng
 
 $rbacreview
 
 $tpl
 
 $settings
 
 $ilias
 

Private Attributes

 $ilErr
 

Detailed Description

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilPasswordAssistanceGUI::__construct ( )

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

References $DIC, and settings().

54  {
55  global $DIC;
56 
57  $this->ctrl = $DIC->ctrl();
58  $this->lng = $DIC->language();
59  $this->rbacreview = $DIC->rbac()->review();
60  $this->tpl = $DIC->ui()->mainTemplate();
61  $this->settings = $DIC->settings();
62  $this->ilias = $DIC['ilias'];
63  $this->ilErr = $DIC['ilErr'];
64  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
redirection script todo: (a better solution should control the processing via a xml file) ...
+ 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 121 of file class.ilPasswordAssistanceGUI.php.

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

Referenced by submitAssistanceForm(), and submitUsernameAssistanceForm().

121  : string
122  {
123  $url = implode('/', [
124  $this->getBaseUrl(),
125  ltrim($script, '/')
126  ]);
127 
129  $url,
130  http_build_query($queryParameters, null, '&')
131  );
132 
133  return $url;
134  }
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
$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 ( )
Returns
mixed

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

References $_GET, $lang, $lng, settings(), showAssignPasswordForm(), and showAssistanceForm().

70  {
71  // check hack attempts
72  if (!$this->settings->get('password_assistance')) {
73  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->FATAL);
74  }
75 
76  // check correct setup
77  if (!$this->settings->get('setup_ok')) {
78  $this->ilErr->raiseError('Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
79  }
80 
81  // Change the language, if necessary.
82  // And load the 'pwassist' language module
83  $lang = $_GET['lang'];
84  if ($lang != null && $lang != '' && $this->lng->getLangKey() != $lang) {
85  $lng = new ilLanguage($lang);
86  }
87  $this->lng->loadLanguageModule('pwassist');
88 
89  $cmd = $this->ctrl->getCmd();
90  $next_class = $this->ctrl->getNextClass($this);
91 
92  switch ($next_class) {
93  default:
94  if ($cmd != '' && method_exists($this, $cmd)) {
95  return $this->$cmd();
96  } else {
97  if (!empty($_GET['key'])) {
98  $this->showAssignPasswordForm();
99  } else {
100  $this->showAssistanceForm();
101  }
102  }
103  break;
104  }
105  }
settings()
Definition: settings.php:2
$_GET["client_id"]
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
showAssistanceForm(ilPropertyFormGUI $form=null)
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
language handling
+ Here is the call graph for this function:

◆ fillPermanentLink()

ilPasswordAssistanceGUI::fillPermanentLink (   $context)
protected
Parameters
string$context

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

References $context.

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

705  {
706  $this->tpl->setPermanentLink('usr', null, $context);
707  }
$context
Definition: webdav.php:25
+ Here is the caller graph for this function:

◆ getAssignPasswordForm()

ilPasswordAssistanceGUI::getAssignPasswordForm (   $pwassist_id)
protected
Parameters
string$pwassist_id
Returns
ilPropertyFormGUI

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

References $form, $key, $password, ilUtil\getPasswordRequirementsInfo(), and ilFormPropertyGUI\setRequired().

Referenced by showAssignPasswordForm(), and submitAssignPasswordForm().

363  {
364  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
365  $form = new ilPropertyFormGUI();
366 
367  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssignPasswordForm'));
368  $form->setTarget('_parent');
369 
370  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
371  $username->setRequired(true);
372  $form->addItem($username);
373 
374  $password = new ilPasswordInputGUI($this->lng->txt('password'), 'password');
376  $password->setRequired(true);
377  $form->addItem($password);
378 
379  $key = new ilHiddenInputGUI('key');
380  $key->setValue($pwassist_id);
381  $form->addItem($key);
382 
383  $form->addCommandButton('submitAssignPasswordForm', $this->lng->txt('submit'));
384 
385  return $form;
386  }
This class represents a property form user interface.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
This class represents a hidden form property in a property form.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
This class represents a password property in a property form.
$password
Definition: cron.php:14
$key
Definition: croninfo.php:18
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssistanceForm()

ilPasswordAssistanceGUI::getAssistanceForm ( )
protected
Returns
ilPropertyFormGUI

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

References $email, $form, and ilFormPropertyGUI\setRequired().

Referenced by showAssistanceForm(), and submitAssistanceForm().

140  {
141  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
142  $form = new ilPropertyFormGUI();
143 
144  $form->setTitle($this->lng->txt('password_assistance'));
145  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssistanceForm'));
146  $form->setTarget('_parent');
147 
148  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
149  $username->setRequired(true);
150  $form->addItem($username);
151 
152  $email = new ilEMailInputGUI($this->lng->txt('email'), 'email');
153  $email->setRequired(true);
154  $form->addItem($email);
155 
156  $form->addCommandButton('submitAssistanceForm', $this->lng->txt('submit'));
157 
158  return $form;
159  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
This class represents a property form user interface.
This class represents a email property in a property form.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
setRequired($a_required)
Set Required.
+ 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 /.

Returns
string

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

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

111  : string
112  {
113  return rtrim(ILIAS_HTTP_PATH, '/');
114  }
+ Here is the caller graph for this function:

◆ getUsernameAssistanceForm()

ilPasswordAssistanceGUI::getUsernameAssistanceForm ( )
protected
Returns
ilPropertyFormGUI

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

References $email, and $form.

Referenced by showUsernameAssistanceForm(), and submitUsernameAssistanceForm().

540  {
541  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
542  $form = new ilPropertyFormGUI();
543 
544  $form->setFormAction($this->ctrl->getFormAction($this, 'submitUsernameAssistanceForm'));
545  $form->setTarget('_parent');
546 
547  $email = new ilTextInputGUI($this->lng->txt('email'), 'email');
548  $email->setRequired(true);
549  $form->addItem($email);
550 
551  $form->addCommandButton('submitUsernameAssistanceForm', $this->lng->txt('submit'));
552 
553  return $form;
554  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
This class represents a property form user interface.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
+ Here is the caller graph for this function:

◆ showAssignPasswordForm()

ilPasswordAssistanceGUI::showAssignPasswordForm ( ilPropertyFormGUI  $form = null,
  $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.

Parameters
ilPropertyFormGUI$form
string$pwassist_id

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

References $_GET, $form, db_pwassist_session_read(), fillPermanentLink(), getAssignPasswordForm(), ilUtil\getImagePath(), ilUtil\sendFailure(), and showAssistanceForm().

Referenced by executeCommand(), and submitAssignPasswordForm().

401  {
402  require_once 'include/inc.pwassist_session_handler.php';
403  require_once 'Services/Language/classes/class.ilLanguage.php';
404 
405  // Retrieve form data
406  if (!$pwassist_id) {
407  $pwassist_id = $_GET['key'];
408  }
409 
410  // Retrieve the session, and check if it is valid
411  $pwassist_session = db_pwassist_session_read($pwassist_id);
412  if (
413  !is_array($pwassist_session) ||
414  count($pwassist_session) == 0 ||
415  $pwassist_session['expires'] < time()
416  ) {
417  ilUtil::sendFailure($this->lng->txt('pwassist_session_expired'));
418  $this->showAssistanceForm(null);
419  } else {
420  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assignpassword.html', true);
421  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
422  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
423 
424  $this->tpl->setVariable('TXT_ENTER_USERNAME_AND_NEW_PASSWORD', $this->lng->txt('pwassist_enter_username_and_new_password'));
425 
426  if (!$form) {
427  $form = $this->getAssignPasswordForm($pwassist_id);
428  }
429  $this->tpl->setVariable('FORM', $form->getHTML());
430  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
431  $this->tpl->show();
432  }
433  }
db_pwassist_session_read($pwassist_id)
$_GET["client_id"]
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
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)
Parameters
ilPropertyFormGUI$form

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

References $form, fillPermanentLink(), getAssistanceForm(), ilUtil\getImagePath(), ilUtil\prepareFormOutput(), and settings().

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

165  {
166  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assistance.html', true);
167  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
168  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
169 
170  $this->tpl->setVariable(
171  'TXT_ENTER_USERNAME_AND_EMAIL',
172  str_replace(
173  "\\n",
174  '<br />',
175  sprintf(
176  $this->lng->txt('pwassist_enter_username_and_email'),
177  '<a href="mailto:' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '">' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
178  )
179  )
180  );
181 
182  if (!$form) {
183  $form = $this->getAssistanceForm();
184  }
185  $this->tpl->setVariable('FORM', $form->getHTML());
186  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
187  $this->tpl->show();
188  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
settings()
Definition: settings.php:2
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMessageForm()

ilPasswordAssistanceGUI::showMessageForm (   $text)

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

Parameters
string$text

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

References $text, fillPermanentLink(), and ilUtil\getImagePath().

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

691  {
692  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
693  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
694  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
695 
696  $this->tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
697  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_NAME);
698  $this->tpl->show();
699  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$text
Definition: errorreport.php:18
+ 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'.

Parameters
ilPropertyFormGUI$form

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

References $form, fillPermanentLink(), ilUtil\getImagePath(), getUsernameAssistanceForm(), ilUtil\prepareFormOutput(), and settings().

Referenced by submitUsernameAssistanceForm().

567  {
568  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_username_assistance.html', true);
569  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
570  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
571 
572  $this->tpl->setVariable(
573  'TXT_ENTER_USERNAME_AND_EMAIL',
574  str_replace(
575  "\\n",
576  '<br />',
577  sprintf(
578  $this->lng->txt('pwassist_enter_email'),
579  '<a href="mailto:' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '">' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
580  )
581  )
582  );
583 
584  if (!$form) {
585  $form = $this->getUsernameAssistanceForm();
586  }
587  $this->tpl->setVariable('FORM', $form->getHTML());
588  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_NAME);
589  $this->tpl->show();
590  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
settings()
Definition: settings.php:2
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ 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 451 of file class.ilPasswordAssistanceGUI.php.

References $_POST, $form, $message, $password, db_pwassist_session_destroy(), db_pwassist_session_read(), getAssignPasswordForm(), ilObjectFactory\getInstanceByObjId(), ilObjUser\getLogin(), ilUtil\isPasswordValidForUserContext(), ilUtil\sendFailure(), showAssignPasswordForm(), showAssistanceForm(), showMessageForm(), ilUtil\stripSlashes(), and ilObject\update().

452  {
453  require_once 'include/inc.pwassist_session_handler.php';
454 
455  // We need to fetch this before form instantiation
456  $pwassist_id = ilUtil::stripSlashes($_POST['key']);
457 
458  $form = $this->getAssignPasswordForm($pwassist_id);
459  if (!$form->checkInput()) {
460  $form->setValuesByPost();
461  $this->showAssistanceForm($form);
462  return;
463  }
464 
465  $username = $form->getInput('username');
466  $password = $form->getInput('password');
467  $pwassist_id = $form->getInput('key');
468 
469  // Retrieve the session
470  $pwassist_session = db_pwassist_session_read($pwassist_id);
471 
472  if (
473  !is_array($pwassist_session) ||
474  count($pwassist_session) == 0 ||
475  $pwassist_session['expires'] < time()
476  ) {
477  ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_session_expired')));
478  $form->setValuesByPost();
479  $this->showAssistanceForm($form);
480  return;
481  } else {
482  $is_successful = true;
483  $message = '';
484 
485  $userObj = \ilObjectFactory::getInstanceByObjId($pwassist_session['user_id'], false);
486  if (!$userObj || !($userObj instanceof \ilObjUser)) {
487  $message = $this->lng->txt('user_does_not_exist');
488  $is_successful = false;
489  }
490 
491  // check if the username entered by the user matches the
492  // one of the user object.
493  if ($is_successful && strcasecmp($userObj->getLogin(), $username) != 0) {
494  $message = $this->lng->txt('pwassist_login_not_match');
495  $is_successful = false;
496  }
497 
498  $error_lng_var = '';
499  if (!ilUtil::isPasswordValidForUserContext($password, $userObj, $error_lng_var)) {
500  $message = $this->lng->txt($error_lng_var);
501  $is_successful = false;
502  }
503 
504  // End of validation
505  // If the validation was successful, we change the password of the
506  // user.
507  // ------------------
508  if ($is_successful) {
509  $is_successful = $userObj->resetPassword($password, $password);
510  if (!$is_successful) {
511  $message = $this->lng->txt('passwd_invalid');
512  }
513  }
514 
515  // If we are successful so far, we update the user object.
516  // ------------------
517  if ($is_successful) {
518  $userObj->update();
519  }
520 
521  // If we are successful, we destroy the password assistance
522  // session and redirect to the login page.
523  // Else we display the form again along with an error message.
524  // ------------------
525  if ($is_successful) {
526  db_pwassist_session_destroy($pwassist_id);
527  $this->showMessageForm(sprintf($this->lng->txt('pwassist_password_assigned'), $username));
528  } else {
529  ilUtil::sendFailure(str_replace("\\n", '', $message));
530  $form->setValuesByPost();
531  $this->showAssignPasswordForm($form, $pwassist_id);
532  }
533  }
534  }
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_read($pwassist_id)
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
catch(Exception $e) $message
if(isset($_POST['submit'])) $form
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
showMessageForm($text)
This form is used to show a message to the user.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showAssistanceForm(ilPropertyFormGUI $form=null)
$password
Definition: cron.php:14
$_POST["username"]
+ 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 201 of file class.ilPasswordAssistanceGUI.php.

References $_SERVER, $DIC, $email, $form, $GLOBALS, $user, AUTH_LOCAL, AUTH_SAML, buildUrl(), db_pwassist_create_id(), db_pwassist_session_find(), db_pwassist_session_write(), getAssistanceForm(), getBaseUrl(), ilObjUser\getEmail(), ilObject\getId(), ilLoggerFactory\getLogger(), ilObjUser\getLogin(), ilObjUser\getUserIdByLogin(), showAssistanceForm(), and showMessageForm().

202  {
203  $form = $this->getAssistanceForm();
204  if (!$form->checkInput()) {
205  $form->setValuesByPost();
206  $this->showAssistanceForm($form);
207  return;
208  }
209 
210  $username = $form->getInput('username');
211  $email = $form->getInput('email');
212 
213  $usrId = \ilObjUser::getUserIdByLogin($username);
214  if (!is_numeric($usrId) || !($usrId > 0)) {
215  \ilLoggerFactory::getLogger('usr')->info(sprintf(
216  'Could not process password assistance form (reason: no user found) %s / %s',
217  $username,
218  $email
219  ));
220 
221  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
222  return;
223  }
224 
225  $defaultAuth = AUTH_LOCAL;
226  if ($GLOBALS['DIC']['ilSetting']->get('auth_mode')) {
227  $defaultAuth = $GLOBALS['DIC']['ilSetting']->get('auth_mode');
228  }
229 
230  $user = new \ilObjUser($usrId);
231  $emailAddresses = array_map('strtolower', [$user->getEmail(), $user->getSecondEmail()]);
232 
233  if (!in_array(strtolower($email), $emailAddresses)) {
234  if (0 === strlen(implode('', $emailAddresses))) {
235  \ilLoggerFactory::getLogger('usr')->info(sprintf(
236  'Could not process password assistance form (reason: account without email addresses): %s / %s',
237  $username,
238  $email
239  ));
240  } else {
241  \ilLoggerFactory::getLogger('usr')->info(sprintf(
242  'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
243  $username,
244  $email
245  ));
246  }
247  } elseif (
248  (
249  $user->getAuthMode(true) != AUTH_LOCAL ||
250  ($user->getAuthMode(true) == $defaultAuth && $defaultAuth != AUTH_LOCAL)
251  ) && !(
252  $user->getAuthMode(true) == AUTH_SAML
253  )
254  ) {
255  \ilLoggerFactory::getLogger('usr')->info(sprintf(
256  'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
257  $username,
258  $email
259  ));
260  } elseif (
261  $this->rbacreview->isAssigned($user->getId(), ANONYMOUS_ROLE_ID) ||
262  $this->rbacreview->isAssigned($user->getId(), SYSTEM_ROLE_ID)
263  ) {
264  \ilLoggerFactory::getLogger('usr')->info(sprintf(
265  'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
266  $username,
267  $email
268  ));
269  } else {
270  $this->sendPasswordAssistanceMail($user);
271  }
272 
273  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
274  }
static getUserIdByLogin($a_login)
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
const AUTH_SAML
if(isset($_POST['submit'])) $form
const AUTH_LOCAL
showMessageForm($text)
This form is used to show a message to the user.
$user
Definition: migrateto20.php:57
showAssistanceForm(ilPropertyFormGUI $form=null)
static getLogger($a_component_id)
Get component logger.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ 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 603 of file class.ilPasswordAssistanceGUI.php.

References $_SERVER, $DIC, $email, $form, buildUrl(), getBaseUrl(), ilLoggerFactory\getLogger(), ilObjUser\getUserLoginsByEmail(), getUsernameAssistanceForm(), showMessageForm(), and showUsernameAssistanceForm().

604  {
605  require_once 'Services/User/classes/class.ilObjUser.php';
606  require_once 'Services/Utilities/classes/class.ilUtil.php';
607 
608  $form = $this->getUsernameAssistanceForm();
609  if (!$form->checkInput()) {
610  $form->setValuesByPost();
612 
613  return;
614  }
615 
616  $email = $form->getInput('email');
618 
619  if (is_array($logins) && count($logins) > 0) {
620  $this->sendUsernameAssistanceMail($email, $logins);
621  } else {
622  \ilLoggerFactory::getLogger('usr')->info(sprintf(
623  'Could not sent username assistance emails to (reason: no user found): %s',
624  $email
625  ));
626  }
627 
628  $this->showMessageForm($this->lng->txt('pwassist_mail_sent_generic'));
629  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
static getUserLoginsByEmail($a_email)
get all user login names of an email address
if(isset($_POST['submit'])) $form
showMessageForm($text)
This form is used to show a message to the user.
static getLogger($a_component_id)
Get component logger.
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilPasswordAssistanceGUI::$ctrl
protected

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

◆ $ilErr

ilPasswordAssistanceGUI::$ilErr
private

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

◆ $ilias

ilPasswordAssistanceGUI::$ilias
protected

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

◆ $lng

ilPasswordAssistanceGUI::$lng
protected

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

Referenced by executeCommand().

◆ $rbacreview

ilPasswordAssistanceGUI::$rbacreview
protected

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

◆ $settings

ilPasswordAssistanceGUI::$settings
protected

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

◆ $tpl

ilPasswordAssistanceGUI::$tpl
protected

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

◆ PERMANENT_LINK_TARGET_NAME

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_NAME = 'nameassist'

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

◆ PERMANENT_LINK_TARGET_PW

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_PW = 'pwassist'

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


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