ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPasswordAssistanceGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
26  private const PERMANENT_LINK_TARGET_PW = 'pwassist';
27  private const PERMANENT_LINK_TARGET_NAME = 'nameassist';
28 
29  private const PROP_USERNAME = 'username';
30  private const PROP_EMAIL = 'email';
31  private const PROP_PASSWORD = 'password';
32  private const PROP_KEY = 'key';
33 
35  private ilLanguage $lng;
42  private ilHelpGUI $help;
45  private ilObjUser $actor;
46 
47  public function __construct()
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->refinery = $DIC->refinery();
60  $this->ui_factory = $DIC->ui()->factory();
61  $this->ui_renderer = $DIC->ui()->renderer();
62  $this->actor = $DIC->user();
63 
64  $this->help->setScreenIdComponent('init');
65  }
66 
67  private function retrieveRequestedKey(): 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  }
84 
85  private function getClientId(): string
86  {
87  return CLIENT_ID;
88  }
89 
90  public function executeCommand(): void
91  {
92  // check correct setup
93  if (!$this->settings->get('setup_ok')) {
94  $this->ilErr->raiseError('Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
95  }
96 
97  // check hack attempts
98  if (!$this->settings->get('password_assistance')) {
99  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
100  }
101 
102  if ($this->actor->getId() > 0 && !$this->actor->isAnonymous()) {
103  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
104  }
105 
106  $this->lng->loadLanguageModule('pwassist');
107  $cmd = $this->ctrl->getCmd() ?? '';
108  $next_class = $this->ctrl->getNextClass($this);
109 
110  switch ($next_class) {
111  default:
112  if ($cmd !== '' && method_exists($this, $cmd)) {
113  $this->$cmd();
114  return;
115  }
116 
117  if ($this->retrieveRequestedKey() !== '') {
118  $this->showAssignPasswordForm(null, $this->retrieveRequestedKey());
119  } else {
120  $this->showAssistanceForm();
121  }
122  break;
123  }
124  }
125 
126  public function getUnsafeGetCommands(): array
127  {
128  return [];
129  }
130 
131  public function getSafePostCommands(): array
132  {
133  return ['submitAssignPasswordForm'];
134  }
135 
136  private function getBaseUrl(): string
137  {
138  return rtrim(ilUtil::_getHttpPath(), '/');
139  }
140 
144  private function buildUrl(string $script, array $query_parameters): string
145  {
146  $url = implode('/', [
147  $this->getBaseUrl(),
148  ltrim($script, '/')
149  ]);
150 
152  $url,
153  http_build_query($query_parameters, '', '&')
154  );
155 
156  return $url;
157  }
158 
159  private function emailTrafo(): \ILIAS\Refinery\Transformation
160  {
161  return $this->refinery->custom()->constraint(
162  static function ($value): bool {
163  return is_string($value) && ilUtil::is_email($value);
164  },
165  $this->lng->txt('email_not_valid')
166  );
167  }
168 
169  private function mergeValuesTrafo(): \ILIAS\Refinery\Transformation
170  {
171  return $this->refinery->custom()->transformation(static function (array $values): array {
172  return array_merge(...$values);
173  });
174  }
175 
176  private function saniziteArrayElementsTrafo(): \ILIAS\Refinery\Transformation
177  {
178  return $this->refinery->custom()->transformation(static function (array $values): array {
179  return ilArrayUtil::stripSlashesRecursive($values);
180  });
181  }
182 
183  private function trimIfStringTrafo(): \ILIAS\Refinery\Transformation
184  {
185  return $this->refinery->custom()->transformation(static function ($value) {
186  if (is_string($value)) {
187  $value = trim($value);
188  }
189 
190  return $value;
191  });
192  }
193 
194  private function getAssistanceForm(): ILIAS\UI\Component\Input\Container\Form\Form
195  {
196  $field_factory = $this->ui_factory->input()->field();
197 
198  return $this->ui_factory
199  ->input()
200  ->container()
201  ->form()
202  ->standard(
203  $this->ctrl->getFormAction($this, 'submitAssistanceForm'),
204  [
205  $field_factory->section(
206  [
207  self::PROP_USERNAME => $field_factory
208  ->text($this->lng->txt('username'))
210  ->withRequired(true),
211  self::PROP_EMAIL => $field_factory
212  ->text($this->lng->txt('email'))
213  ->withRequired(true)
214  ->withAdditionalTransformation($this->trimIfStringTrafo())
215  ->withAdditionalTransformation($this->emailTrafo()),
216  ],
217  $this->lng->txt('password_assistance'),
218  ''
219  ),
220  ]
221  )
222  ->withSubmitLabel($this->lng->txt('submit'))
225  }
226 
227  private function showAssistanceForm(ILIAS\UI\Component\Input\Container\Form\Form $form = null): void
228  {
229  $this->help->setSubScreenId('password_assistance');
230 
231  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assistance.html', true);
232  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
233  $tpl->setVariable(
234  'IMG_PAGEHEADLINE',
235  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
236  ilUtil::getImagePath('standard/icon_auth.svg'),
237  $this->lng->txt('password_assistance')
238  ))
239  );
240 
241  $tpl->setVariable(
242  'TXT_ENTER_USERNAME_AND_EMAIL',
243  $this->ui_renderer->render(
244  $this->ui_factory->messageBox()->info(
245  str_replace(
246  "\\n",
247  '<br />',
248  sprintf(
249  $this->lng->txt('pwassist_enter_username_and_email'),
250  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
251  $this->settings->get('admin_email')
252  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
253  )
254  )
255  )
256  )
257  );
258 
259  $tpl->setVariable('FORM', $this->ui_renderer->render($form ?? $this->getAssistanceForm()));
260  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
262  }
263 
271  private function submitAssistanceForm(): void
272  {
273  $form = $this->getAssistanceForm();
274  $form_valid = false;
275  $form_data = null;
276  if ($this->http->request()->getMethod() === 'POST') {
277  $form = $form->withRequest($this->http->request());
278  $form_data = $form->getData();
279  $form_valid = $form_data !== null;
280  }
281 
282  if (!$form_valid) {
283  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
284  $this->showAssistanceForm($form);
285  return;
286  }
287 
288  $defaultAuth = ilAuthUtils::AUTH_LOCAL;
289  if ($GLOBALS['DIC']['ilSetting']->get('auth_mode')) {
290  $defaultAuth = $GLOBALS['DIC']['ilSetting']->get('auth_mode');
291  }
292 
293  $username = $form_data[self::PROP_USERNAME];
294  $email = $form_data[self::PROP_EMAIL];
295 
296  $assistance_callback = function () use ($defaultAuth, $username, $email): void {
297  $usr_id = ilObjUser::getUserIdByLogin($username);
298  if (!is_numeric($usr_id) || !($usr_id > 0)) {
299  ilLoggerFactory::getLogger('usr')->info(
300  sprintf(
301  'Could not process password assistance form (reason: no user found) %s / %s',
302  $username,
303  $email
304  )
305  );
306  return;
307  }
308 
309  $user = new ilObjUser($usr_id);
310  $email_addresses = array_map('strtolower', [$user->getEmail(), $user->getSecondEmail()]);
311 
312  if (!in_array(strtolower($email), $email_addresses, true)) {
313  if (implode('', $email_addresses) === '') {
314  ilLoggerFactory::getLogger('usr')->info(
315  sprintf(
316  'Could not process password assistance form (reason: account without email addresses): %s / %s',
317  $username,
318  $email
319  )
320  );
321  } else {
322  ilLoggerFactory::getLogger('usr')->info(
323  sprintf(
324  'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
325  $username,
326  $email
327  )
328  );
329  }
330  } elseif (
331  (
332  $user->getAuthMode(true) != ilAuthUtils::AUTH_LOCAL ||
333  ($user->getAuthMode(true) == $defaultAuth && $defaultAuth != ilAuthUtils::AUTH_LOCAL)
334  ) && !(
335  (int) $user->getAuthMode(true) === ilAuthUtils::AUTH_SAML &&
336  \ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))
337  )
338  ) {
339  ilLoggerFactory::getLogger('usr')->info(
340  sprintf(
341  'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
342  $username,
343  $email
344  )
345  );
346  } elseif ($this->rbacreview->isAssigned($user->getId(), ANONYMOUS_ROLE_ID) ||
347  $this->rbacreview->isAssigned($user->getId(), SYSTEM_ROLE_ID)) {
348  ilLoggerFactory::getLogger('usr')->info(
349  sprintf(
350  'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
351  $username,
352  $email
353  )
354  );
355  } else {
356  $this->sendPasswordAssistanceMail($user);
357  }
358  };
359 
360  if (($assistance_duration = $this->settings->get('account_assistance_duration')) !== null) {
361  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
362  $status = $duration->stretch($assistance_callback);
363  } else {
364  $status = $assistance_callback();
365  }
366 
367  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email), self::PERMANENT_LINK_TARGET_PW);
368  }
369 
380  private function sendPasswordAssistanceMail(ilObjUser $userObj): void
381  {
382  global $DIC;
383 
384  require_once 'include/inc.pwassist_session_handler.php';
385  $pwassist_session['pwassist_id'] = db_pwassist_create_id();
387  $pwassist_session['pwassist_id'],
388  3600,
389  $userObj->getId()
390  );
391 
392  $pwassist_url = $this->buildUrl(
393  'pwassist.php',
394  [
395  'client_id' => $this->getClientId(),
396  'lang' => $this->lng->getLangKey(),
397  'key' => $pwassist_session['pwassist_id']
398  ]
399  );
400 
401  $alternative_pwassist_url = $this->buildUrl(
402  'pwassist.php',
403  [
404  'client_id' => $this->getClientId(),
405  'lang' => $this->lng->getLangKey(),
406  'key' => $pwassist_session['pwassist_id']
407  ]
408  );
409 
411  $senderFactory = $DIC->mail()->mime()->senderFactory();
412  $sender = $senderFactory->system();
413 
414  $mm = new ilMimeMail();
415  $mm->Subject($this->lng->txt('pwassist_mail_subject'), true);
416  $mm->From($sender);
417  $mm->To($userObj->getEmail());
418  $mm->Body(
419  str_replace(
420  ["\\n", "\\t"],
421  ["\n", "\t"],
422  sprintf(
423  $this->lng->txt('pwassist_mail_body'),
424  $pwassist_url,
425  $this->getBaseUrl() . '/',
426  $_SERVER['REMOTE_ADDR'],
427  $userObj->getLogin(),
428  'mailto:' . $DIC->settings()->get('admin_email'),
429  $alternative_pwassist_url
430  )
431  )
432  );
433  $mm->Send();
434  }
435 
436  private function getAssignPasswordForm(string $pwassist_id = null): ILIAS\UI\Component\Input\Container\Form\Form
437  {
438  $field_factory = $this->ui_factory->input()->field();
439 
440  $key = $field_factory
441  ->hidden()
442  ->withRequired(true)
443  ->withDedicatedName(self::PROP_KEY);
444  if ($pwassist_id !== null) {
445  $key = $key->withValue($pwassist_id);
446  }
447 
448  return $this->ui_factory
449  ->input()
450  ->container()
451  ->form()
452  ->standard(
453  $this->ctrl->getFormAction($this, 'submitAssignPasswordForm'),
454  [
455  $field_factory->section(
456  [
457  self::PROP_KEY => $key,
458  self::PROP_USERNAME => $field_factory
459  ->text($this->lng->txt('username'))
461  ->withRequired(true),
462  self::PROP_PASSWORD => $field_factory
463  ->password(
464  $this->lng->txt('password'),
466  )
467  ->withRequired(true)
468  ->withRevelation(true)
469  ->withAdditionalTransformation(
470  $this->refinery->custom()->constraint(
471  static function (ILIAS\Data\Password $value): bool {
473  trim($value->toString())
474  );
475  },
476  static function (Closure $lng, ILIAS\Data\Password $value): string {
477  $problem = $lng('passwd_invalid');
478  $custom_problem = null;
480  trim($value->toString()),
481  $custom_problem
482  )) {
483  $problem = $custom_problem;
484  }
485 
486  return $problem;
487  }
488  )
489  )
490  ->withAdditionalTransformation(
491  $this->refinery->custom()->transformation(
492  static function (ILIAS\Data\Password $value): string {
493  return trim($value->toString());
494  }
495  )
496  ),
497  ],
498  $this->lng->txt('password_assistance'),
499  ''
500  ),
501  ]
502  )
503  ->withSubmitLabel($this->lng->txt('submit'))
506  }
507 
518  private function showAssignPasswordForm(
519  ILIAS\UI\Component\Input\Container\Form\Form $form = null,
520  string $pwassist_id = ''
521  ): void {
522  $this->help->setSubScreenId('password_input');
523 
524  if ($pwassist_id === '') {
525  $pwassist_id = $this->retrieveRequestedKey();
526  }
527 
528  require_once 'include/inc.pwassist_session_handler.php';
529  $pwassist_session = db_pwassist_session_read($pwassist_id);
530  if (!is_array($pwassist_session) || $pwassist_session['expires'] < time()) {
531  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('pwassist_session_expired'));
532  $this->showAssistanceForm(null);
533  return;
534  }
535 
536  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assignpassword.html', true);
537  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
538  $tpl->setVariable(
539  'IMG_PAGEHEADLINE',
540  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
541  ilUtil::getImagePath('standard/icon_auth.svg'),
542  $this->lng->txt('password_assistance')
543  ))
544  );
545 
546  $tpl->setVariable(
547  'TXT_ENTER_USERNAME_AND_NEW_PASSWORD',
548  $this->ui_renderer->render(
549  $this->ui_factory->messageBox()->info($this->lng->txt('pwassist_enter_username_and_new_password'))
550  )
551  );
552 
553  $tpl->setVariable('FORM', $this->ui_renderer->render($form ?? $this->getAssignPasswordForm($pwassist_id)));
554  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
556  }
557 
568  private function submitAssignPasswordForm(): void
569  {
570  $form = $this->getAssignPasswordForm();
571  $form_valid = false;
572  $form_data = null;
573  if ($this->http->request()->getMethod() === 'POST') {
574  $form = $form->withRequest($this->http->request());
575  $form_data = $form->getData();
576  $form_valid = $form_data !== null;
577  }
578 
579  if (!$form_valid) {
580  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
581  $this->showAssistanceForm($form);
582  return;
583  }
584 
585  $username = $form_data[self::PROP_USERNAME];
586  $password = $form_data[self::PROP_PASSWORD];
587  $pwassist_id = $form_data[self::PROP_KEY];
588 
589  require_once 'include/inc.pwassist_session_handler.php';
590  $pwassist_session = db_pwassist_session_read($pwassist_id);
591  if (!is_array($pwassist_session) || $pwassist_session['expires'] < time()) {
592  $this->tpl->setOnScreenMessage(
593  'failure',
594  str_replace("\\n", '', $this->lng->txt('pwassist_session_expired'))
595  );
596  $this->showAssistanceForm($form);
597  } else {
598  $is_successful = true;
599  $message = '';
600 
601  $userObj = ilObjectFactory::getInstanceByObjId((int) $pwassist_session['user_id'], false);
602  if (!($userObj instanceof ilObjUser)) {
603  $message = $this->lng->txt('user_does_not_exist');
604  $is_successful = false;
605  }
606 
607  // check if the username entered by the user matches the
608  // one of the user object.
609  if ($is_successful && strcasecmp($userObj->getLogin(), $username) !== 0) {
610  $message = $this->lng->txt('pwassist_login_not_match');
611  $is_successful = false;
612  }
613 
614  $error_lng_var = '';
615  if ($is_successful &&
616  !ilSecuritySettingsChecker::isPasswordValidForUserContext($password, $userObj, $error_lng_var)) {
617  $message = $this->lng->txt($error_lng_var);
618  $is_successful = false;
619  }
620 
621  // End of validation
622  // If the validation was successful, we change the password of the
623  // user.
624  // ------------------
625  if ($is_successful) {
626  $is_successful = $userObj->resetPassword($password, $password);
627  if (!$is_successful) {
628  $message = $this->lng->txt('passwd_invalid');
629  }
630  }
631 
632  // If we are successful so far, we update the user object.
633  // ------------------
634  if ($is_successful) {
635  $userObj->setLastPasswordChangeToNow();
636  $userObj->update();
637  }
638 
639  // If we are successful, we destroy the password assistance
640  // session and redirect to the login page.
641  // Else we display the form again along with an error message.
642  // ------------------
643  if ($is_successful) {
644  db_pwassist_session_destroy($pwassist_id);
645  $this->showMessageForm(
646  $this->ui_renderer->render(
647  $this->ui_factory->messageBox()->info(
648  sprintf($this->lng->txt('pwassist_password_assigned'), $username)
649  )
650  ),
651  self::PERMANENT_LINK_TARGET_PW
652  );
653  } else {
654  $this->tpl->setOnScreenMessage('failure', str_replace("\\n", '', $message));
655  $this->showAssignPasswordForm($form, $pwassist_id);
656  }
657  }
658  }
659 
660  private function getUsernameAssistanceForm(): ILIAS\UI\Component\Input\Container\Form\Form
661  {
662  $field_factory = $this->ui_factory->input()->field();
663 
664  return $this->ui_factory
665  ->input()
666  ->container()
667  ->form()
668  ->standard(
669  $this->ctrl->getFormAction($this, 'submitUsernameAssistanceForm'),
670  [
671  $field_factory->section(
672  [
673  self::PROP_EMAIL => $field_factory
674  ->text($this->lng->txt('email'))
675  ->withRequired(true)
676  ->withAdditionalTransformation($this->trimIfStringTrafo())
677  ->withAdditionalTransformation($this->emailTrafo()),
678  ],
679  $this->lng->txt('username_assistance'),
680  ''
681  ),
682  ]
683  )
684  ->withSubmitLabel($this->lng->txt('submit'))
687  }
688 
689  private function showUsernameAssistanceForm(ILIAS\UI\Component\Input\Container\Form\Form $form = null): void
690  {
691  $this->help->setSubScreenId('username_assistance');
692 
693  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_username_assistance.html', true);
694  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
695  $tpl->setVariable(
696  'IMG_PAGEHEADLINE',
697  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
698  ilUtil::getImagePath('standard/icon_auth.svg'),
699  $this->lng->txt('password_assistance')
700  ))
701  );
702 
703  $tpl->setVariable(
704  'TXT_ENTER_USERNAME_AND_EMAIL',
705  $this->ui_renderer->render(
706  $this->ui_factory->messageBox()->info(
707  str_replace(
708  "\\n",
709  '<br />',
710  sprintf(
711  $this->lng->txt('pwassist_enter_email'),
712  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
713  $this->settings->get('admin_email')
714  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
715  )
716  )
717  )
718  )
719  );
720 
721  $tpl->setVariable('FORM', $this->ui_renderer->render($form ?? $this->getUsernameAssistanceForm()));
722  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_NAME);
724  }
725 
726  private function submitUsernameAssistanceForm(): void
727  {
728  $form = $this->getUsernameAssistanceForm();
729  $form_valid = false;
730  $form_data = null;
731  if ($this->http->request()->getMethod() === 'POST') {
732  $form = $form->withRequest($this->http->request());
733  $form_data = $form->getData();
734  $form_valid = $form_data !== null;
735  }
736 
737  if (!$form_valid) {
738  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
739  $this->showUsernameAssistanceForm($form);
740  return;
741  }
742 
743  $email = trim($form_data[self::PROP_EMAIL]);
744 
745  $assistance_callback = function () use ($email): void {
746  $logins = ilObjUser::getUserLoginsByEmail($email);
747 
748  if (is_array($logins) && count($logins) > 0) {
749  $this->sendUsernameAssistanceMail($email, $logins);
750  } else {
751  ilLoggerFactory::getLogger('usr')->info(
752  sprintf(
753  'Could not sent username assistance emails to (reason: no user found): %s',
754  $email
755  )
756  );
757  }
758  };
759 
760  if (($assistance_duration = $this->settings->get('account_assistance_duration')) !== null) {
761  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
762  $status = $duration->stretch($assistance_callback);
763  } else {
764  $status = $assistance_callback();
765  }
766 
767  $this->showMessageForm($this->lng->txt('pwassist_mail_sent_generic'), self::PERMANENT_LINK_TARGET_NAME);
768  }
769 
773  private function sendUsernameAssistanceMail(string $email, array $logins): void
774  {
775  global $DIC;
776 
777  $login_url = $this->buildUrl(
778  'pwassist.php',
779  [
780  'client_id' => $this->getClientId(),
781  'lang' => $this->lng->getLangKey()
782  ]
783  );
784 
785  $senderFactory = $DIC->mail()->mime()->senderFactory();
786  $sender = $senderFactory->system();
787 
788  $mm = new ilMimeMail();
789  $mm->Subject($this->lng->txt('pwassist_mail_subject'), true);
790  $mm->From($sender);
791  $mm->To($email);
792  $mm->Body(
793  str_replace(
794  ["\\n", "\\t"],
795  ["\n", "\t"],
796  sprintf(
797  $this->lng->txt('pwassist_username_mail_body'),
798  implode(",\n", $logins),
799  $this->getBaseUrl() . '/',
800  $_SERVER['REMOTE_ADDR'],
801  $email,
802  'mailto:' . $this->settings->get('admin_email'),
803  $login_url
804  )
805  )
806  );
807  $mm->Send();
808  }
809 
810  private function showMessageForm(string $text, string $permanent_link_context): void
811  {
812  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
813  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
814  $tpl->setVariable(
815  'IMG_PAGEHEADLINE',
816  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
817  ilUtil::getImagePath('standard/icon_auth.svg'),
818  $this->lng->txt('password_assistance')
819  ))
820  );
821 
822  $tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
823  $this->fillPermanentLink($permanent_link_context);
825  }
826 
827  private function fillPermanentLink(string $context): void
828  {
829  $this->tpl->setPermanentLink('usr', null, $context);
830  }
831 }
buildUrl(string $script, array $query_parameters)
static initStartUpTemplate( $a_tmpl, bool $a_show_back=false, bool $a_show_logout=false)
This method enriches the global template with some user interface elements (language selection...
resetPassword(string $raw, string $raw_retype)
Resets the user password.
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
$context
Definition: webdav.php:31
static getLogger(string $a_component_id)
Get component logger.
static is_email(string $a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
db_pwassist_session_destroy(string $pwassist_id)
db_pwassist_create_id()
Creates a new secure id.
showUsernameAssistanceForm(ILIAS\UI\Component\Input\Container\Form\Form $form=null)
Class ChatMainBarProvider .
showAssignPasswordForm(ILIAS\UI\Component\Input\Container\Form\Form $form=null, string $pwassist_id='')
Assign password form.
const SYSTEM_ROLE_ID
Definition: constants.php:29
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
showAssistanceForm(ILIAS\UI\Component\Input\Container\Form\Form $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isPassword(string $a_passwd, ?string &$customError=null)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static prepareFormOutput($a_str, bool $a_strip=false)
$duration
static printToGlobalTemplate($tpl)
global $DIC
Definition: feed.php:28
static getUserIdByLogin(string $a_login)
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:31
db_pwassist_session_read(string $pwassist_id)
static getUserLoginsByEmail(string $a_email)
db_pwassist_session_write(string $pwassist_id, int $maxlifetime, int $user_id)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
showMessageForm(string $text, string $permanent_link_context)
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
const CLIENT_ID
Definition: constants.php:41
string $key
Consumer key/client ID value.
Definition: System.php:193
$url
Definition: ltiregstart.php:35
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
sendUsernameAssistanceMail(string $email, array $logins)
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
submitAssignPasswordForm()
The key is used to retrieve the password assistance session.
Error Handling & global info handling.
static _getHttpPath()
submitAssistanceForm()
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.
getSafePostCommands()
This method must return a list of safe POST commands.
$message
Definition: xapiexit.php:32
setLastPasswordChangeToNow()
Interface ilCtrlSecurityInterface provides ilCtrl security information.
getAssignPasswordForm(string $pwassist_id=null)