File modules/cms/action/user/UserPwAction.class.php
Last commit: Fri Apr 15 20:45:19 2022 +0200 dankert Refactoring: Code cleanup.
1 <?php 2 namespace cms\action\user; 3 use cms\action\Method; 4 use cms\action\UserAction; 5 use cms\base\Configuration; 6 use cms\model\User; 7 use language\Messages; 8 use security\Password; 9 use util\exception\ValidationException; 10 use util\mail\Mail; 11 12 13 class UserPwAction extends UserAction implements Method { 14 15 public function view() { 16 $this->setTemplateVar('enabled',$this->user->type == User::AUTH_TYPE_INTERNAL ); 17 $this->setTemplateVar('mail' ,(boolean) $this->user->mail ); 18 19 $this->setTemplateVar('password_proposal', Password::createPassword() ); 20 } 21 22 23 public function post() { 24 $password = $this->request->getText('password'); 25 26 if ( !$password ) 27 $password = $this->request->getText('password_proposal'); 28 29 if ( strlen($password) < Configuration::subset(['security','password'])->get('min_length',8) ) 30 throw new ValidationException('password',Messages::PASSWORD_MINLENGTH ); 31 32 $this->user->setPassword($password,!$this->request->isTrue('timeout') ); // Kennwort setzen 33 34 // E-Mail mit dem neuen Kennwort an Benutzer senden 35 if ( $this->request->isTrue('email') && 36 $this->user->mail && // user has an e-mail. 37 Configuration::subset('mail')->is('enabled',true) 38 ) { 39 $eMail = new Mail($this->user->mail, Messages::MAIL_SUBJECT_PASSWORD_NEW,Messages::MAIL_TEXT_PASSWORD_NEW); 40 $eMail->setVar('name' ,$this->user->getName()); 41 $eMail->setVar('password',$password ); 42 $eMail->send(); 43 $this->addNoticeFor( $this->user, Messages::MAIL_SENT); 44 } 45 46 $this->addNoticeFor($this->user, Messages::SAVED); 47 48 } 49 }
Downloadmodules/cms/action/user/UserPwAction.class.php
History Fri, 15 Apr 2022 20:45:19 +0200 dankert Refactoring: Code cleanup. Wed, 9 Mar 2022 13:28:52 +0100 dankert Refactoring: Checkbox values are always sent to the server. In the actions we must test the value with 'isTrue()' Mon, 6 Dec 2021 21:44:58 +0100 dankert Fix: Possibility to send the new passowrd to the user. Wed, 10 Mar 2021 23:51:22 +0100 Jan Dankert Refactoring: Cleaned the Request params. Fri, 26 Feb 2021 01:06:01 +0100 Jan Dankert Refactoring accessing the request parameter values. Tue, 17 Nov 2020 23:51:00 +0100 Jan Dankert Refactoring: Every Actionmethod has now its own class.