openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

LoginRegisterAction.class.php (1252B)


      1 <?php
      2 namespace cms\action\login;
      3 use cms\action\LoginAction;
      4 use cms\action\Method;
      5 use cms\action\RequestParams;
      6 use cms\model\User;
      7 use language\Messages;
      8 use logger\Logger;
      9 use util\exception\ValidationException;
     10 use util\mail\Mail;
     11 use util\Session;
     12 use util\text\TextMessage;
     13 
     14 
     15 class LoginRegisterAction extends LoginAction implements Method {
     16     public function view() {
     17 
     18     }
     19 
     20     public function post() {
     21 
     22 		$email_address = $this->request->getValidMail('mail');
     23 
     24 		Session::set( Session::KEY_REGISTER_MAIL,$email_address );
     25 		
     26 		srand ((double)microtime()*1000003);
     27 		$registerCode = rand();
     28 		
     29 		Session::set( Session::KEY_REGISTER_CODE,$registerCode  );
     30 
     31 
     32 		// E-Mail and die eingegebene Adresse verschicken
     33 		$mail = new Mail($email_address, Messages::MAIL_SUBJECT_REGISTER_COMMIT_CODE,Messages::MAIL_TEXT_REGISTER_COMMIT_CODE);
     34 		$mail->setVar('code',$registerCode); // Registrierungscode als Text-Variable
     35 
     36 		try {
     37 			$mail->send();
     38 			$this->addNoticeFor( new User(), Messages::MAIL_SENT);
     39 		} catch( \Exception $e ) {
     40 			Logger::warn( new \Exception(TextMessage::create('Mail could not be sent for unregistered user with adress ${0}', [$email_address]), $e) );
     41 			$this->addErrorFor( new User(),Messages::MAIL_NOT_SENT);
     42 		}
     43     }
     44 }