ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilPasswordAssistanceGUI Class Reference
+ 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...
 

Private Member Functions

 retrieveRequestedKey ()
 
 getClientId ()
 
 getBaseUrl ()
 
 buildUrl (string $script, array $query_parameters)
 
 emailTrafo ()
 
 mergeValuesTrafo ()
 
 saniziteArrayElementsTrafo ()
 
 trimIfStringTrafo ()
 
 getAssistanceForm ()
 
 showAssistanceForm (?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
 
 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. More...
 
 getAssignPasswordForm (?string $pwassist_id=null)
 
 getUsernameAssistanceForm ()
 
 showUsernameAssistanceForm (?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
 
 submitUsernameAssistanceForm ()
 
 sendUsernameAssistanceMail (string $email, array $logins)
 
 showMessageForm (string $text, string $permanent_link_context)
 
 fillPermanentLink (string $context)
 

Private Attributes

const PERMANENT_LINK_TARGET_PW = 'pwassist'
 
const PERMANENT_LINK_TARGET_NAME = 'nameassist'
 
const PROP_USERNAME = 'username'
 
const PROP_EMAIL = 'email'
 
const PROP_PASSWORD = 'password'
 
const PROP_KEY = 'key'
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilRbacReview $rbacreview
 
ilGlobalTemplateInterface $tpl
 
ilSetting $settings
 
ilErrorHandling $ilErr
 
RefineryFactory $refinery
 
HTTPServices $http
 
ilHelpGUI $help
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 
ilObjUser $actor
 
ILIAS Data Clock ClockInterface $clock
 
ILIAS Init PasswordAssitance PasswordAssistanceRepository $pwa_repository
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilPasswordAssistanceGUI::__construct ( )

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

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

50  {
51  global $DIC;
52 
53  $this->ctrl = $DIC->ctrl();
54  $this->lng = $DIC->language();
55  $this->rbacreview = $DIC->rbac()->review();
56  $this->tpl = $DIC->ui()->mainTemplate();
57  $this->settings = $DIC->settings();
58  $this->ilErr = $DIC['ilErr'];
59  $this->help = $DIC->help();
60  $this->http = $DIC->http();
61  $this->refinery = $DIC->refinery();
62  $this->ui_factory = $DIC->ui()->factory();
63  $this->ui_renderer = $DIC->ui()->renderer();
64  $this->actor = $DIC->user();
65  $this->clock = (new ILIAS\Data\Factory())->clock()->utc();
66  $this->pwa_repository = new \ILIAS\Init\PasswordAssitance\Repository\PasswordAssistanceDbRepository(
67  $DIC->database(),
69  );
70  $this->help->setScreenIdComponent('init');
71  }
ILIAS Data Clock ClockInterface $clock
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ buildUrl()

ilPasswordAssistanceGUI::buildUrl ( string  $script,
array  $query_parameters 
)
private
Parameters
array<string,string>$query_parameters

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

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

Referenced by sendUsernameAssistanceMail(), and submitAssistanceForm().

150  : string
151  {
152  $url = implode('/', [
153  $this->getBaseUrl(),
154  ltrim($script, '/')
155  ]);
156 
158  $url,
159  http_build_query($query_parameters, '', '&')
160  );
161 
162  return $url;
163  }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
$url
Definition: shib_logout.php:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ emailTrafo()

ilPasswordAssistanceGUI::emailTrafo ( )
private

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

References ilUtil\is_email(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by getAssistanceForm(), and getUsernameAssistanceForm().

165  : \ILIAS\Refinery\Transformation
166  {
167  return $this->refinery->custom()->constraint(
168  static function ($value): bool {
169  return is_string($value) && ilUtil::is_email($value);
170  },
171  $this->lng->txt('email_not_valid')
172  );
173  }
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilPasswordAssistanceGUI::executeCommand ( )

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

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

96  : void
97  {
98  // check correct setup
99  if (!$this->settings->get('setup_ok')) {
100  $this->ilErr->raiseError('Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
101  }
102 
103  // check hack attempts
104  if (!$this->settings->get('password_assistance')) {
105  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
106  }
107 
108  if ($this->actor->getId() > 0 && !$this->actor->isAnonymous()) {
109  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
110  }
111 
112  $this->lng->loadLanguageModule('pwassist');
113  $cmd = $this->ctrl->getCmd() ?? '';
114  $next_class = $this->ctrl->getNextClass($this);
115 
116  switch ($next_class) {
117  default:
118  if ($cmd !== '' && method_exists($this, $cmd)) {
119  $this->$cmd();
120  return;
121  }
122 
123  if ($this->retrieveRequestedKey() !== '') {
124  $this->showAssignPasswordForm(null, $this->retrieveRequestedKey());
125  } else {
126  $this->showAssistanceForm();
127  }
128  break;
129  }
130  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
showAssistanceForm(?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
+ Here is the call graph for this function:

◆ fillPermanentLink()

ilPasswordAssistanceGUI::fillPermanentLink ( string  $context)
private

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

References null.

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

853  : void
854  {
855  $this->tpl->setPermanentLink('usr', null, $context);
856  }
$context
Definition: webdav.php:31
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getAssignPasswordForm()

ilPasswordAssistanceGUI::getAssignPasswordForm ( ?string  $pwassist_id = null)
private

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

References $lng, $message, ILIAS\Repository\ctrl(), fillPermanentLink(), ilUtil\getImagePath(), ilObjectFactory\getInstanceByObjId(), ilObjUser\getLogin(), ilSecuritySettingsChecker\getPasswordRequirementsInfo(), ILIAS\Repository\help(), ILIAS\FileDelivery\http(), ilStartUpGUI\initStartUpTemplate(), ilSecuritySettingsChecker\isPassword(), ilSecuritySettingsChecker\isPasswordValidForUserContext(), ILIAS\Repository\lng(), mergeValuesTrafo(), null, ilStartUpGUI\printToGlobalTemplate(), ILIAS\Repository\refinery(), ilObjUser\resetPassword(), retrieveRequestedKey(), saniziteArrayElementsTrafo(), ilObjUser\setLastPasswordChangeToNow(), ILIAS\UICore\GlobalTemplate\setVariable(), showAssistanceForm(), showMessageForm(), trimIfStringTrafo(), ilObjUser\update(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

440  {
441  $field_factory = $this->ui_factory->input()->field();
442 
443  $key = $field_factory
444  ->hidden()
445  ->withRequired(true)
446  ->withDedicatedName(self::PROP_KEY);
447  if ($pwassist_id !== null) {
448  $key = $key->withValue($pwassist_id);
449  }
450 
451  return $this->ui_factory
452  ->input()
453  ->container()
454  ->form()
455  ->standard(
456  $this->ctrl->getFormAction($this, 'submitAssignPasswordForm'),
457  [
458  $field_factory->section(
459  [
460  self::PROP_KEY => $key,
461  self::PROP_USERNAME => $field_factory
462  ->text($this->lng->txt('username'))
464  ->withRequired(true),
465  self::PROP_PASSWORD => $field_factory
466  ->password(
467  $this->lng->txt('password'),
469  )
470  ->withRequired(true)
471  ->withRevelation(true)
472  ->withAdditionalTransformation(
473  $this->refinery->custom()->constraint(
474  static function (ILIAS\Data\Password $value): bool {
476  trim($value->toString())
477  );
478  },
479  static function (Closure $lng, ILIAS\Data\Password $value): string {
480  $problem = $lng('passwd_invalid');
481  $custom_problem = null;
483  trim($value->toString()),
484  $custom_problem
485  )) {
486  $problem = $custom_problem;
487  }
488 
489  return $problem;
490  }
491  )
492  )
493  ->withAdditionalTransformation(
494  $this->refinery->custom()->transformation(
495  static function (ILIAS\Data\Password $value): string {
496  return trim($value->toString());
497  }
498  )
499  ),
500  ],
501  $this->lng->txt('password_assistance'),
502  ''
503  ),
504  ]
505  )
506  ->withSubmitLabel($this->lng->txt('submit'))
509  }
Interface Observer Contains several chained tasks and infos about them.
static isPassword(string $a_passwd, ?string &$customError=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
+ Here is the call graph for this function:

◆ getAssistanceForm()

ilPasswordAssistanceGUI::getAssistanceForm ( )
private

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

References ILIAS\Repository\ctrl(), emailTrafo(), ILIAS\Repository\lng(), mergeValuesTrafo(), saniziteArrayElementsTrafo(), trimIfStringTrafo(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

Referenced by submitAssistanceForm().

201  {
202  $field_factory = $this->ui_factory->input()->field();
203 
204  return $this->ui_factory
205  ->input()
206  ->container()
207  ->form()
208  ->standard(
209  $this->ctrl->getFormAction($this, 'submitAssistanceForm'),
210  [
211  $field_factory->section(
212  [
213  self::PROP_USERNAME => $field_factory
214  ->text($this->lng->txt('username'))
216  ->withRequired(true),
217  self::PROP_EMAIL => $field_factory
218  ->text($this->lng->txt('email'))
219  ->withRequired(true)
220  ->withAdditionalTransformation($this->trimIfStringTrafo())
221  ->withAdditionalTransformation($this->emailTrafo()),
222  ],
223  $this->lng->txt('password_assistance'),
224  ''
225  ),
226  ]
227  )
228  ->withSubmitLabel($this->lng->txt('submit'))
231  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseUrl()

ilPasswordAssistanceGUI::getBaseUrl ( )
private

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

References ilUtil\_getHttpPath().

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

142  : string
143  {
144  return rtrim(ilUtil::_getHttpPath(), '/');
145  }
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClientId()

ilPasswordAssistanceGUI::getClientId ( )
private

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

References CLIENT_ID.

Referenced by sendUsernameAssistanceMail(), and submitAssistanceForm().

91  : string
92  {
93  return CLIENT_ID;
94  }
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 137 of file class.ilPasswordAssistanceGUI.php.

137  : array
138  {
139  return ['submitAssignPasswordForm'];
140  }

◆ 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 132 of file class.ilPasswordAssistanceGUI.php.

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

◆ getUsernameAssistanceForm()

ilPasswordAssistanceGUI::getUsernameAssistanceForm ( )
private

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

References ILIAS\Repository\ctrl(), emailTrafo(), ILIAS\Repository\lng(), mergeValuesTrafo(), saniziteArrayElementsTrafo(), trimIfStringTrafo(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

Referenced by submitUsernameAssistanceForm().

687  {
688  $field_factory = $this->ui_factory->input()->field();
689 
690  return $this->ui_factory
691  ->input()
692  ->container()
693  ->form()
694  ->standard(
695  $this->ctrl->getFormAction($this, 'submitUsernameAssistanceForm'),
696  [
697  $field_factory->section(
698  [
699  self::PROP_EMAIL => $field_factory
700  ->text($this->lng->txt('email'))
701  ->withRequired(true)
702  ->withAdditionalTransformation($this->trimIfStringTrafo())
703  ->withAdditionalTransformation($this->emailTrafo()),
704  ],
705  $this->lng->txt('username_assistance'),
706  ''
707  ),
708  ]
709  )
710  ->withSubmitLabel($this->lng->txt('submit'))
713  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mergeValuesTrafo()

ilPasswordAssistanceGUI::mergeValuesTrafo ( )
private

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

References ILIAS\Repository\refinery().

Referenced by getAssignPasswordForm(), getAssistanceForm(), and getUsernameAssistanceForm().

175  : \ILIAS\Refinery\Transformation
176  {
177  return $this->refinery->custom()->transformation(static function (array $values): array {
178  return array_merge(...$values);
179  });
180  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveRequestedKey()

ilPasswordAssistanceGUI::retrieveRequestedKey ( )
private

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

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by executeCommand(), and getAssignPasswordForm().

73  : string
74  {
75  $key = $this->http->wrapper()->query()->retrieve(
76  'key',
77  $this->refinery->byTrying([
78  $this->refinery->kindlyTo()->string(),
79  $this->refinery->always(
80  $this->http->wrapper()->post()->retrieve(
81  'key',
82  $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
83  )
84  )
85  ])
86  );
87 
88  return $key;
89  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saniziteArrayElementsTrafo()

ilPasswordAssistanceGUI::saniziteArrayElementsTrafo ( )
private

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

References ILIAS\Repository\refinery(), and ilArrayUtil\stripSlashesRecursive().

Referenced by getAssignPasswordForm(), getAssistanceForm(), and getUsernameAssistanceForm().

182  : \ILIAS\Refinery\Transformation
183  {
184  return $this->refinery->custom()->transformation(static function (array $values): array {
185  return ilArrayUtil::stripSlashesRecursive($values);
186  });
187  }
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendUsernameAssistanceMail()

ilPasswordAssistanceGUI::sendUsernameAssistanceMail ( string  $email,
array  $logins 
)
private
Parameters
list<string>$logins

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

References $_SERVER, $DIC, buildUrl(), getBaseUrl(), getClientId(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

Referenced by submitUsernameAssistanceForm().

799  : void
800  {
801  global $DIC;
802 
803  $login_url = $this->buildUrl(
804  'pwassist.php',
805  [
806  'client_id' => $this->getClientId(),
807  'lang' => $this->lng->getLangKey()
808  ]
809  );
810 
811  $senderFactory = $DIC->mail()->mime()->senderFactory();
812  $sender = $senderFactory->system();
813 
814  $mm = new ilMimeMail();
815  $mm->Subject($this->lng->txt('pwassist_mail_subject'), true);
816  $mm->From($sender);
817  $mm->To($email);
818  $mm->Body(
819  str_replace(
820  ["\\n", "\\t"],
821  ["\n", "\t"],
822  sprintf(
823  $this->lng->txt('pwassist_username_mail_body'),
824  implode(",\n", $logins),
825  $this->getBaseUrl() . '/',
826  $_SERVER['REMOTE_ADDR'],
827  $email,
828  'mailto:' . $this->settings->get('admin_email'),
829  $login_url
830  )
831  )
832  );
833  $mm->Send();
834  }
buildUrl(string $script, array $query_parameters)
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssistanceForm()

ilPasswordAssistanceGUI::showAssistanceForm ( ?ILIAS\UI\Component\Input\Container\Form\Form  $form = null)
private

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

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

Referenced by executeCommand(), getAssignPasswordForm(), and submitAssistanceForm().

233  : void
234  {
235  $this->help->setSubScreenId('password_assistance');
236 
237  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assistance.html', true);
238  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
239  $tpl->setVariable(
240  'IMG_PAGEHEADLINE',
241  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
242  ilUtil::getImagePath('standard/icon_auth.svg'),
243  $this->lng->txt('password_assistance')
244  ))
245  );
246 
247  $tpl->setVariable(
248  'TXT_ENTER_USERNAME_AND_EMAIL',
249  $this->ui_renderer->render(
250  $this->ui_factory->messageBox()->info(
251  str_replace(
252  "\\n",
253  '<br />',
254  sprintf(
255  $this->lng->txt('pwassist_enter_username_and_email'),
256  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
257  $this->settings->get('admin_email')
258  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
259  )
260  )
261  )
262  )
263  );
264 
265  $tpl->setVariable('FORM', $this->ui_renderer->render($form ?? $this->getAssistanceForm()));
266  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_PW);
268  }
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...
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static printToGlobalTemplate($tpl)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $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 ( string  $text,
string  $permanent_link_context 
)
private

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

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

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

836  : void
837  {
838  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
839  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
840  $tpl->setVariable(
841  'IMG_PAGEHEADLINE',
842  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
843  ilUtil::getImagePath('standard/icon_auth.svg'),
844  $this->lng->txt('password_assistance')
845  ))
846  );
847 
848  $tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
849  $this->fillPermanentLink($permanent_link_context);
851  }
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...
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static printToGlobalTemplate($tpl)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $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:

◆ showUsernameAssistanceForm()

ilPasswordAssistanceGUI::showUsernameAssistanceForm ( ?ILIAS\UI\Component\Input\Container\Form\Form  $form = null)
private

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

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

Referenced by submitUsernameAssistanceForm().

715  : void
716  {
717  $this->help->setSubScreenId('username_assistance');
718 
719  $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_username_assistance.html', true);
720  $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
721  $tpl->setVariable(
722  'IMG_PAGEHEADLINE',
723  $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
724  ilUtil::getImagePath('standard/icon_auth.svg'),
725  $this->lng->txt('password_assistance')
726  ))
727  );
728 
729  $tpl->setVariable(
730  'TXT_ENTER_USERNAME_AND_EMAIL',
731  $this->ui_renderer->render(
732  $this->ui_factory->messageBox()->info(
733  str_replace(
734  "\\n",
735  '<br />',
736  sprintf(
737  $this->lng->txt('pwassist_enter_email'),
738  '<a href="mailto:' . ilLegacyFormElementsUtil::prepareFormOutput(
739  $this->settings->get('admin_email')
740  ) . '">' . ilLegacyFormElementsUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
741  )
742  )
743  )
744  )
745  );
746 
747  $tpl->setVariable('FORM', $this->ui_renderer->render($form ?? $this->getUsernameAssistanceForm()));
748  $this->fillPermanentLink(self::PERMANENT_LINK_TARGET_NAME);
750  }
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...
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static printToGlobalTemplate($tpl)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $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:

◆ submitAssistanceForm()

ilPasswordAssistanceGUI::submitAssistanceForm ( )
private

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 277 of file class.ilPasswordAssistanceGUI.php.

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

277  : void
278  {
279  $form = $this->getAssistanceForm();
280  $form_valid = false;
281  $form_data = null;
282  if ($this->http->request()->getMethod() === 'POST') {
283  $form = $form->withRequest($this->http->request());
284  $form_data = $form->getData();
285  $form_valid = $form_data !== null;
286  }
287 
288  if (!$form_valid) {
289  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
290  $this->showAssistanceForm($form);
291  return;
292  }
293 
294  $defaultAuth = ilAuthUtils::AUTH_LOCAL;
295  if ($GLOBALS['DIC']['ilSetting']->get('auth_mode')) {
296  $defaultAuth = $GLOBALS['DIC']['ilSetting']->get('auth_mode');
297  }
298 
299  $username = $form_data[self::PROP_USERNAME];
300  $email = $form_data[self::PROP_EMAIL];
301 
302  $assistance_callback = function () use ($defaultAuth, $username, $email): void {
303  $usr_id = ilObjUser::getUserIdByLogin($username);
304  if (!is_numeric($usr_id) || !($usr_id > 0)) {
305  ilLoggerFactory::getLogger('usr')->info(
306  sprintf(
307  'Could not process password assistance form (reason: no user found) %s / %s',
308  $username,
309  $email
310  )
311  );
312  return;
313  }
314 
315  $user = new ilObjUser($usr_id);
316  $email_addresses = array_map('strtolower', [$user->getEmail(), $user->getSecondEmail()]);
317 
318  if (!in_array(strtolower($email), $email_addresses, true)) {
319  if (implode('', $email_addresses) === '') {
320  ilLoggerFactory::getLogger('usr')->info(
321  sprintf(
322  'Could not process password assistance form (reason: account without email addresses): %s / %s',
323  $username,
324  $email
325  )
326  );
327  } else {
328  ilLoggerFactory::getLogger('usr')->info(
329  sprintf(
330  'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
331  $username,
332  $email
333  )
334  );
335  }
336  } elseif (
337  (
338  $user->getAuthMode(true) != ilAuthUtils::AUTH_LOCAL ||
339  ($user->getAuthMode(true) == $defaultAuth && $defaultAuth != ilAuthUtils::AUTH_LOCAL)
340  ) && !(
341  (int) $user->getAuthMode(true) === ilAuthUtils::AUTH_SAML &&
342  \ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))
343  )
344  ) {
345  ilLoggerFactory::getLogger('usr')->info(
346  sprintf(
347  'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
348  $username,
349  $email
350  )
351  );
352  } elseif ($this->rbacreview->isAssigned($user->getId(), ANONYMOUS_ROLE_ID) ||
353  $this->rbacreview->isAssigned($user->getId(), SYSTEM_ROLE_ID)) {
354  ilLoggerFactory::getLogger('usr')->info(
355  sprintf(
356  'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
357  $username,
358  $email
359  )
360  );
361  } else {
362  $this->sendPasswordAssistanceMail($user);
363  }
364  };
365 
366  if (($assistance_duration = $this->settings->get('account_assistance_duration')) !== null) {
367  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
368  $status = $duration->stretch($assistance_callback);
369  } else {
370  $status = $assistance_callback();
371  }
372 
373  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email), self::PERMANENT_LINK_TARGET_PW);
374  }
static getLogger(string $a_component_id)
Get component logger.
const SYSTEM_ROLE_ID
Definition: constants.php:29
$duration
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getUserIdByLogin(string $a_login)
const int AUTH_LOCAL
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:53
showMessageForm(string $text, string $permanent_link_context)
showAssistanceForm(?ILIAS\UI\Component\Input\Container\Form\Form $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.
const int AUTH_SAML
+ Here is the call graph for this function:

◆ submitUsernameAssistanceForm()

ilPasswordAssistanceGUI::submitUsernameAssistanceForm ( )
private

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

References $duration, ilLoggerFactory\getLogger(), ilObjUser\getUserLoginsByEmail(), getUsernameAssistanceForm(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, sendUsernameAssistanceMail(), ILIAS\Repository\settings(), showMessageForm(), and showUsernameAssistanceForm().

752  : void
753  {
754  $form = $this->getUsernameAssistanceForm();
755  $form_valid = false;
756  $form_data = null;
757  if ($this->http->request()->getMethod() === 'POST') {
758  $form = $form->withRequest($this->http->request());
759  $form_data = $form->getData();
760  $form_valid = $form_data !== null;
761  }
762 
763  if (!$form_valid) {
764  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
765  $this->showUsernameAssistanceForm($form);
766  return;
767  }
768 
769  $email = trim($form_data[self::PROP_EMAIL]);
770 
771  $assistance_callback = function () use ($email): void {
772  $logins = ilObjUser::getUserLoginsByEmail($email);
773 
774  if (is_array($logins) && count($logins) > 0) {
775  $this->sendUsernameAssistanceMail($email, $logins);
776  } else {
777  ilLoggerFactory::getLogger('usr')->info(
778  sprintf(
779  'Could not sent username assistance emails to (reason: no user found): %s',
780  $email
781  )
782  );
783  }
784  };
785 
786  if (($assistance_duration = $this->settings->get('account_assistance_duration')) !== null) {
787  $duration = $this->http->durations()->callbackDuration((int) $assistance_duration);
788  $status = $duration->stretch($assistance_callback);
789  } else {
790  $status = $assistance_callback();
791  }
792 
793  $this->showMessageForm($this->lng->txt('pwassist_mail_sent_generic'), self::PERMANENT_LINK_TARGET_NAME);
794  }
static getLogger(string $a_component_id)
Get component logger.
$duration
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
static getUserLoginsByEmail(string $a_email)
showMessageForm(string $text, string $permanent_link_context)
showUsernameAssistanceForm(?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
sendUsernameAssistanceMail(string $email, array $logins)
+ Here is the call graph for this function:

◆ trimIfStringTrafo()

ilPasswordAssistanceGUI::trimIfStringTrafo ( )
private

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

References ILIAS\Repository\refinery().

Referenced by getAssignPasswordForm(), getAssistanceForm(), and getUsernameAssistanceForm().

189  : \ILIAS\Refinery\Transformation
190  {
191  return $this->refinery->custom()->transformation(static function ($value) {
192  if (is_string($value)) {
193  $value = trim($value);
194  }
195 
196  return $value;
197  });
198  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $actor

ilObjUser ilPasswordAssistanceGUI::$actor
private

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

◆ $clock

ILIAS Data Clock ClockInterface ilPasswordAssistanceGUI::$clock
private

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

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilPasswordAssistanceGUI::$ctrl
private

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

◆ $help

ilHelpGUI ilPasswordAssistanceGUI::$help
private

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

◆ $http

HTTPServices ilPasswordAssistanceGUI::$http
private

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

◆ $ilErr

ilErrorHandling ilPasswordAssistanceGUI::$ilErr
private

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

◆ $lng

ilLanguage ilPasswordAssistanceGUI::$lng
private

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

Referenced by getAssignPasswordForm().

◆ $pwa_repository

ILIAS Init PasswordAssitance PasswordAssistanceRepository ilPasswordAssistanceGUI::$pwa_repository
private

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

◆ $rbacreview

ilRbacReview ilPasswordAssistanceGUI::$rbacreview
private

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

◆ $refinery

RefineryFactory ilPasswordAssistanceGUI::$refinery
private

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

◆ $settings

ilSetting ilPasswordAssistanceGUI::$settings
private

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

◆ $tpl

ilGlobalTemplateInterface ilPasswordAssistanceGUI::$tpl
private

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

◆ $ui_factory

ILIAS UI Factory ilPasswordAssistanceGUI::$ui_factory
private

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

◆ $ui_renderer

ILIAS UI Renderer ilPasswordAssistanceGUI::$ui_renderer
private

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

◆ PERMANENT_LINK_TARGET_NAME

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_NAME = 'nameassist'
private

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

◆ PERMANENT_LINK_TARGET_PW

const ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_PW = 'pwassist'
private

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

◆ PROP_EMAIL

const ilPasswordAssistanceGUI::PROP_EMAIL = 'email'
private

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

◆ PROP_KEY

const ilPasswordAssistanceGUI::PROP_KEY = 'key'
private

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

◆ PROP_PASSWORD

const ilPasswordAssistanceGUI::PROP_PASSWORD = 'password'
private

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

◆ PROP_USERNAME

const ilPasswordAssistanceGUI::PROP_USERNAME = 'username'
private

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


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