Beispiel #1
0
 /**
  * The method registers website users and set their status to new at start. It also generate verification token.
  * @param RegisterForm $registerForm
  * @return User
  */
 public static function register($registerForm)
 {
     $user = new User();
     $date = DateUtil::getDateTime();
     $user->email = $registerForm->email;
     $user->username = $registerForm->username;
     $user->firstName = $registerForm->firstName;
     $user->lastName = $registerForm->lastName;
     $user->newsletter = $registerForm->newsletter;
     $user->registeredAt = $date;
     $user->status = User::STATUS_NEW;
     $user->generatePassword($registerForm->password);
     $user->generateVerifyToken();
     $user->generateAuthKey();
     $user->save();
     // Add to mailing list
     if ($user->newsletter) {
         NewsletterMemberService::create($user->email, $user->getName());
     }
     return $user;
 }
Beispiel #2
0
 public static function checkNewsletterMember($user)
 {
     $member = NewsletterMemberService::findByEmail($user->email);
     // Update mailing list
     if (isset($member) && $member->active) {
         $user->newsletter = true;
     }
 }