ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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...
 
 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)
 
 buildSystemMailBody (string $content)
 Appends the installation signature using line breaks that match the resolved mail body format. More...
 

Private Attributes

const string PERMANENT_LINK_TARGET_PW = 'password'
 
const string PERMANENT_LINK_TARGET_NAME = 'username'
 
const string PROP_USERNAME = 'username'
 
const string PROP_EMAIL = 'email'
 
const string PROP_PASSWORD = 'password'
 
const string 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
 
readonly ILIAS Mail Service MailSignatureService $signature_service
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilPasswordAssistanceGUI::__construct ( )

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

51 {
52 global $DIC;
53
54 $this->ctrl = $DIC->ctrl();
55 $this->lng = $DIC->language();
56 $this->rbacreview = $DIC->rbac()->review();
57 $this->tpl = $DIC->ui()->mainTemplate();
58 $this->settings = $DIC->settings();
59 $this->ilErr = $DIC['ilErr'];
60 $this->help = $DIC->help();
61 $this->http = $DIC->http();
62 $this->refinery = $DIC->refinery();
63 $this->ui_factory = $DIC->ui()->factory();
64 $this->ui_renderer = $DIC->ui()->renderer();
65 $this->actor = $DIC->user();
66 $this->clock = (new ILIAS\Data\Factory())->clock()->utc();
67 $this->pwa_repository = new \ILIAS\Init\PasswordAssitance\Repository\PasswordAssistanceDbRepository(
68 $DIC->database(),
69 $this->clock
70 );
71 $this->help->setScreenIdComponent('init');
72 $this->signature_service = $DIC->mail()->signature();
73 }
Builds data types.
Definition: Factory.php:36
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildSystemMailBody()

ilPasswordAssistanceGUI::buildSystemMailBody ( string  $content)
private

Appends the installation signature using line breaks that match the resolved mail body format.

This should be not needed once "Mail" does not accept primitive strings anymore but supports real "Text" handling {

See also
docs/development/text-representation.md}

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

861 : string
862 {
863 $body = str_replace(["\\n", "\\t"], ["\n", "\t"], $content);
864 $signature = $this->signature_service->installation();
865
866 if (strip_tags($body) !== $body) {
867 $signature = nl2br($signature);
868 }
869
870 return $body . $signature;
871 }
$body
Definition: ltiauth.php:41

References $body.

◆ buildUrl()

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

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

152 : string
153 {
154 $url = implode('/', [
155 $this->getBaseUrl(),
156 ltrim($script, '/')
157 ]);
158
160 $url,
161 http_build_query($query_parameters, '', '&')
162 );
163
164 return $url;
165 }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)

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

+ Here is the call graph for this function:

◆ emailTrafo()

ilPasswordAssistanceGUI::emailTrafo ( )
private

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

168 {
169 return $this->refinery->custom()->constraint(
170 static function ($value): bool {
171 return is_string($value) && ilUtil::is_email($value);
172 },
173 $this->lng->txt('email_not_valid')
174 );
175 }
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
A transformation is a function from one datatype to another.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilPasswordAssistanceGUI::executeCommand ( )

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

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

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

+ Here is the call graph for this function:

◆ fillPermanentLink()

ilPasswordAssistanceGUI::fillPermanentLink ( string  $context)
private

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

851 : void
852 {
853 $this->tpl->setPermanentLink('assistant', null, $context);
854 }

Referenced by showAssistanceForm().

+ 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.

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'))
463 ->withAdditionalTransformation($this->trimIfStringTrafo())
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 }
A password is used as part of credentials for authentication.
Definition: Password.php:31
static isPassword(string $a_passwd, ?string &$customError=null)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
withDedicatedName(string $dedicated_name)
Sets an optional dedicated name for this form which adds a NAME attribute to the form's HTML (otherwi...
This describes commonalities between all forms.
Definition: Form.php:34
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References $lng, ILIAS\Repository\ctrl(), ilSecuritySettingsChecker\getPasswordRequirementsInfo(), ilSecuritySettingsChecker\isPassword(), ILIAS\Repository\lng(), mergeValuesTrafo(), ILIAS\User\Settings\Password, ILIAS\Repository\refinery(), saniziteArrayElementsTrafo(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

+ Here is the call graph for this function:

◆ getAssistanceForm()

ilPasswordAssistanceGUI::getAssistanceForm ( )
private

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

203 {
204 $field_factory = $this->ui_factory->input()->field();
205
206 return $this->ui_factory
207 ->input()
208 ->container()
209 ->form()
210 ->standard(
211 $this->ctrl->getFormAction($this, 'submitAssistanceForm'),
212 [
213 $field_factory->section(
214 [
215 self::PROP_USERNAME => $field_factory
216 ->text($this->lng->txt('username'))
217 ->withAdditionalTransformation($this->trimIfStringTrafo())
218 ->withRequired(true),
219 self::PROP_EMAIL => $field_factory
220 ->text($this->lng->txt('email'))
221 ->withRequired(true)
222 ->withAdditionalTransformation($this->trimIfStringTrafo())
223 ->withAdditionalTransformation($this->emailTrafo()),
224 ],
225 $this->lng->txt('password_assistance'),
226 ''
227 ),
228 ]
229 )
230 ->withSubmitLabel($this->lng->txt('submit'))
232 ->withAdditionalTransformation($this->saniziteArrayElementsTrafo());
233 }
withAdditionalTransformation(Transformation $trafo)
Apply a transformation to the data of the form.

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

Referenced by submitAssistanceForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBaseUrl()

ilPasswordAssistanceGUI::getBaseUrl ( )
private

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

144 : string
145 {
146 return rtrim(ilUtil::_getHttpPath(), '/');
147 }
static _getHttpPath()

References ilUtil\_getHttpPath().

Referenced by buildUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClientId()

ilPasswordAssistanceGUI::getClientId ( )
private

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

93 : string
94 {
95 return CLIENT_ID;
96 }
const CLIENT_ID
Definition: constants.php:41

References CLIENT_ID.

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

139 : array
140 {
141 return ['submitAssignPasswordForm'];
142 }

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

134 : array
135 {
136 return [];
137 }

◆ getUsernameAssistanceForm()

ilPasswordAssistanceGUI::getUsernameAssistanceForm ( )
private

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

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'))
712 ->withAdditionalTransformation($this->saniziteArrayElementsTrafo());
713 }

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

+ Here is the call graph for this function:

◆ mergeValuesTrafo()

ilPasswordAssistanceGUI::mergeValuesTrafo ( )
private

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

178 {
179 return $this->refinery->custom()->transformation(static function (array $values): array {
180 return array_merge(...$values);
181 });
182 }

References ILIAS\Repository\refinery().

Referenced by getAssignPasswordForm(), and getAssistanceForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveRequestedKey()

ilPasswordAssistanceGUI::retrieveRequestedKey ( )
private

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

75 : string
76 {
77 $key = $this->http->wrapper()->query()->retrieve(
78 'key',
79 $this->refinery->byTrying([
80 $this->refinery->kindlyTo()->string(),
81 $this->refinery->always(
82 $this->http->wrapper()->post()->retrieve(
83 'key',
84 $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
85 )
86 )
87 ])
88 );
89
90 return $key;
91 }

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

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saniziteArrayElementsTrafo()

ilPasswordAssistanceGUI::saniziteArrayElementsTrafo ( )
private

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

185 {
186 return $this->refinery->custom()->transformation(static function (array $values): array {
188 });
189 }
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")

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

Referenced by getAssignPasswordForm(), and getAssistanceForm().

+ 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.

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 $this->buildSystemMailBody(
820 sprintf(
821 $this->lng->txt('pwassist_username_mail_body'),
822 implode(",\n", $logins),
823 $this->getBaseUrl() . '/',
824 $_SERVER['REMOTE_ADDR'],
825 $email,
826 'mailto:' . $this->settings->get('admin_email'),
827 $login_url
828 )
829 )
830 );
831 $mm->Send();
832 }
buildSystemMailBody(string $content)
Appends the installation signature using line breaks that match the resolved mail body format.
buildUrl(string $script, array $query_parameters)

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ showAssistanceForm()

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

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

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

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

Referenced by executeCommand(), and submitAssistanceForm().

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

834 : void
835 {
836 $tpl = ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
837 $tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
839 'IMG_PAGEHEADLINE',
840 $this->ui_renderer->render($this->ui_factory->symbol()->icon()->custom(
841 ilUtil::getImagePath('standard/icon_auth.svg'),
842 $this->lng->txt('password_assistance')
843 ))
844 );
845
846 $tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
847 $this->fillPermanentLink($permanent_link_context);
849 }
$text
Definition: xapiexit.php:21

References $text, ILIAS\News\Common\Table\$tpl, ilUtil\getImagePath(), ilStartUpGUI\initStartUpTemplate(), ILIAS\Repository\lng(), ilStartUpGUI\printToGlobalTemplate(), and ILIAS\UICore\GlobalTemplate\setVariable().

Referenced by submitAssistanceForm().

+ 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.

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'));
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
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'),
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 }

References ILIAS\News\Common\Table\$tpl, ilUtil\getImagePath(), ILIAS\Repository\help(), ilStartUpGUI\initStartUpTemplate(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\prepareFormOutput(), ilStartUpGUI\printToGlobalTemplate(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call 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 279 of file class.ilPasswordAssistanceGUI.php.

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

References $duration, $GLOBALS, ANONYMOUS_ROLE_ID, ilAuthUtils\AUTH_LOCAL, ilAuthUtils\AUTH_SAML, getAssistanceForm(), ilLoggerFactory\getLogger(), ilObjUser\getUserIdByLogin(), ILIAS\FileDelivery\http(), ilAuthUtils\isLocalPasswordEnabledForAuthMode(), ILIAS\Repository\lng(), PROP_EMAIL, PROP_USERNAME, ILIAS\Repository\settings(), showAssistanceForm(), showMessageForm(), and SYSTEM_ROLE_ID.

+ Here is the call graph for this function:

◆ submitUsernameAssistanceForm()

ilPasswordAssistanceGUI::submitUsernameAssistanceForm ( )
private

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

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 getUserLoginsByEmail(string $a_email)
showUsernameAssistanceForm(?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
sendUsernameAssistanceMail(string $email, array $logins)

References $duration, ilLoggerFactory\getLogger(), ilObjUser\getUserLoginsByEmail(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ trimIfStringTrafo()

ilPasswordAssistanceGUI::trimIfStringTrafo ( )
private

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

192 {
193 return $this->refinery->custom()->transformation(static function ($value) {
194 if (is_string($value)) {
195 $value = trim($value);
196 }
197
198 return $value;
199 });
200 }

References ILIAS\Repository\refinery().

+ Here is the call 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.

◆ $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.

◆ $signature_service

readonly ILIAS Mail Service MailSignatureService ilPasswordAssistanceGUI::$signature_service
private

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

◆ $tpl

ilGlobalTemplateInterface ilPasswordAssistanceGUI::$tpl
private

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

Referenced by showAssistanceForm().

◆ $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 string ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_NAME = 'username'
private

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

◆ PERMANENT_LINK_TARGET_PW

const string ilPasswordAssistanceGUI::PERMANENT_LINK_TARGET_PW = 'password'
private

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

◆ PROP_EMAIL

const string ilPasswordAssistanceGUI::PROP_EMAIL = 'email'
private

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

Referenced by submitAssistanceForm().

◆ PROP_KEY

const string ilPasswordAssistanceGUI::PROP_KEY = 'key'
private

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

◆ PROP_PASSWORD

const string ilPasswordAssistanceGUI::PROP_PASSWORD = 'password'
private

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

◆ PROP_USERNAME

const string ilPasswordAssistanceGUI::PROP_USERNAME = 'username'
private

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

Referenced by submitAssistanceForm().


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