ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLocalUserPasswordSettingsGUI Class Reference
+ Collaboration diagram for ilLocalUserPasswordSettingsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 showPassword (?Form $form=null, bool $hide_form=false, ?MessageBox $message_box=null)
 
 getPasswordForm (?ServerRequestInterface $request=null, array $errors=[])
 

Data Fields

const string CMD_SHOW_PASSWORD = 'showPassword'
 
const string CMD_SAVE_PASSWORD = 'savePassword'
 

Private Attributes

const string NEW_PASSWORD = 'new_password'
 
const string CURRENT_PASSWORD = 'current_password'
 
readonly ServerRequestInterface $request
 
readonly ilErrorHandling $error
 
readonly Refinery $refinery
 
readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilLanguage $lng
 
readonly ilObjUser $user
 
readonly ilCtrlInterface $ctrl
 
readonly LocalUserPasswordManager $password_manager
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilLocalUserPasswordSettingsGUI::__construct ( )

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

49 {
50 global $DIC;
51 $this->user = $DIC->user();
52 $this->ctrl = $DIC->ctrl();
53 $this->error = $DIC['ilErr'];
54 $this->lng = $DIC->language();
55 $this->refinery = $DIC->refinery();
56 $this->tpl = $DIC->ui()->mainTemplate();
57 $this->request = $DIC->http()->request();
58 $this->ui_factory = $DIC->ui()->factory();
59 $this->ui_renderer = $DIC->ui()->renderer();
60 $this->password_manager = LocalUserPasswordManager::getInstance();
61 $this->lng->loadLanguageModule('user');
62 }
error(string $a_errmsg)
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), error(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilLocalUserPasswordSettingsGUI::executeCommand ( )

Definition at line 64 of file class.ilLocalUserPasswordSettingsGUI.php.

64 : void
65 {
66 $this->tpl->setTitle($this->lng->txt('chg_password'));
67 $cmd = $this->ctrl->getCmd();
68 switch ($cmd) {
69 default:
70 if (method_exists($this, $cmd)) {
71 $this->$cmd();
72 } else {
73 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
74 }
75
76 break;
77 }
78 }

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

+ Here is the call graph for this function:

◆ getPasswordForm()

ilLocalUserPasswordSettingsGUI::getPasswordForm ( ?ServerRequestInterface  $request = null,
array  $errors = [] 
)

Definition at line 107 of file class.ilLocalUserPasswordSettingsGUI.php.

110 : Form {
111 $items = [];
112 if ($this->password_manager->allowPasswordChange($this->user)) {
113 $pw_info_set = false;
114 if ((int) $this->user->getAuthMode(true) === ilAuthUtils::AUTH_LOCAL) {
115 $cpass = $this->ui_factory->input()->field()->password(
116 $this->lng->txt(self::CURRENT_PASSWORD),
118 );
119
120 $pw_info_set = true;
121 if ($this->user->getPasswd()) {
122 $cpass = $cpass->withRequired(true);
123 }
124 $cpass = $cpass->withRevelation(true);
125 $cpass_error = $errors[self::CURRENT_PASSWORD] ?? [];
126 if ($cpass_error !== []) {
127 $cpass = $cpass->withError(implode('<br>', $cpass_error));
128 }
129 $cpass = $cpass->withAdditionalTransformation(
130 $this->refinery->custom()->constraint(function (Password $value): bool {
131 return
132 ((int) $this->user->getAuthMode(true) !== ilAuthUtils::AUTH_LOCAL) ||
133 LocalUserPasswordManager::getInstance()->verifyPassword(
134 $this->user,
135 $value->toString()
136 );
137 }, $this->lng->txt('passwd_wrong'))
138 );
139
140 $items[self::CURRENT_PASSWORD] = $cpass;
141 }
142
143 // new password
144 $ipass = $this->ui_factory->input()->field()->password(
145 $this->lng->txt('desired_password'),
146 );
147 if ($pw_info_set === false) {
148 $ipass = $ipass->withByline(ilSecuritySettingsChecker::getPasswordRequirementsInfo());
149 }
150 $ipass = $ipass->withRequired(true);
151 $ipass = $ipass->withRevelation(true);
152 $ipass_error = $errors[self::NEW_PASSWORD] ?? [];
153 if ($ipass_error !== []) {
154 $ipass = $ipass->withError(implode('<br>', $ipass_error));
155 }
156 $ipass = $ipass->withAdditionalTransformation(
157 $this->refinery->custom()->constraint(function (Password $value): bool {
158 return ilSecuritySettingsChecker::isPassword($value->toString(), $custom_error);
159 }, function (Closure $txt, Password $value): string {
160 $custom_error = '';
161 !ilSecuritySettingsChecker::isPassword($value->toString(), $custom_error);
162 if ($custom_error !== '' && $custom_error !== null) {
163 return $custom_error;
164 }
165
166 return $this->lng->txt('passwd_invalid');
167 })
168 );
169 $ipass = $ipass->withAdditionalTransformation(
170 $this->refinery->custom()->constraint(
171 function (Password $value): bool {
173 $value->toString(),
174 $this->user,
175 $error_lng_var
176 );
177 },
178 function (Closure $cls, Password $value): string {
180 $value->toString(),
181 $this->user,
182 $error_lng_var
183 );
184
185 return $this->lng->txt($error_lng_var ?? '');
186 }
187 )
188 );
189 $items[self::NEW_PASSWORD] = $ipass;
190
191 switch ($this->user->getAuthMode(true)) {
193 $title = $this->lng->txt('chg_password');
194
195 break;
197 default:
198 $title = $this->lng->txt('chg_ilias_password');
199
200 break;
201 }
202 $section = $this->ui_factory->input()->field()->section($items, $title);
203 $items = ['password' => $section];
204 }
205
206 return $this->ui_factory->input()->container()->form()->standard(
207 $this->ctrl->getLinkTarget($this, 'savePassword'),
208 $items
209 )->withSubmitLabel($this->lng->txt('save'));
210 }
A password is used as part of credentials for authentication.
Definition: Password.php:31
const int AUTH_SHIBBOLETH
const int AUTH_LOCAL
static isPassword(string $a_passwd, ?string &$customError=null)
static isPasswordValidForUserContext(string $clear_text_password, $user, ?string &$error_language_variable=null)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
$txt
Definition: error.php:31

References $txt, ilAuthUtils\AUTH_LOCAL, ilAuthUtils\AUTH_SHIBBOLETH, ilSecuritySettingsChecker\getPasswordRequirementsInfo(), ilSecuritySettingsChecker\isPassword(), ilSecuritySettingsChecker\isPasswordValidForUserContext(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Data\Password\toString(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ showPassword()

ilLocalUserPasswordSettingsGUI::showPassword ( ?Form  $form = null,
bool  $hide_form = false,
?MessageBox  $message_box = null 
)

Definition at line 80 of file class.ilLocalUserPasswordSettingsGUI.php.

84 : void {
85 // check whether password of user have to be changed
86 // due to first login or password of user is expired
87 if ($this->user->isPasswordChangeDemanded()) {
88 $this->tpl->setOnScreenMessage(
89 $this->tpl::MESSAGE_TYPE_INFO,
90 $this->lng->txt('password_change_on_first_login_demand')
91 );
92 } elseif ($this->user->isPasswordExpired()) {
93 $msg = $this->lng->txt('password_expired');
94 $password_age = $this->user->getPasswordAge();
95 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_INFO, sprintf($msg, $password_age));
96 }
97
98 if (!$form && !$hide_form) {
99 $form = $this->getPasswordForm();
100 }
101 $this->tpl->setContent(
102 !$hide_form ? $this->ui_renderer->render($form) : $this->ui_renderer->render($message_box)
103 );
104 $this->tpl->printToStdout();
105 }
getPasswordForm(?ServerRequestInterface $request=null, array $errors=[])

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

readonly ilCtrlInterface ilLocalUserPasswordSettingsGUI::$ctrl
private

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

◆ $error

readonly ilErrorHandling ilLocalUserPasswordSettingsGUI::$error
private

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

◆ $lng

readonly ilLanguage ilLocalUserPasswordSettingsGUI::$lng
private

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

◆ $password_manager

readonly LocalUserPasswordManager ilLocalUserPasswordSettingsGUI::$password_manager
private

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

◆ $refinery

readonly Refinery ilLocalUserPasswordSettingsGUI::$refinery
private

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

◆ $request

readonly ServerRequestInterface ilLocalUserPasswordSettingsGUI::$request
private

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

◆ $tpl

readonly ilGlobalTemplateInterface ilLocalUserPasswordSettingsGUI::$tpl
private

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

◆ $ui_factory

readonly UIFactory ilLocalUserPasswordSettingsGUI::$ui_factory
private

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

◆ $ui_renderer

readonly UIRenderer ilLocalUserPasswordSettingsGUI::$ui_renderer
private

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

◆ $user

readonly ilObjUser ilLocalUserPasswordSettingsGUI::$user
private

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

◆ CMD_SAVE_PASSWORD

const string ilLocalUserPasswordSettingsGUI::CMD_SAVE_PASSWORD = 'savePassword'

◆ CMD_SHOW_PASSWORD

◆ CURRENT_PASSWORD

const string ilLocalUserPasswordSettingsGUI::CURRENT_PASSWORD = 'current_password'
private

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

◆ NEW_PASSWORD

const string ilLocalUserPasswordSettingsGUI::NEW_PASSWORD = 'new_password'
private

Definition at line 33 of file class.ilLocalUserPasswordSettingsGUI.php.


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