function register($googleUser)
 {
     $user = new User();
     $date = DateUtil::getDateTime();
     $user->email = $googleUser->email;
     $user->firstName = $googleUser->given_name;
     $user->lastName = $googleUser->family_name;
     $user->newsletter = 0;
     $user->registeredAt = $date;
     $user->status = User::STATUS_ACTIVE;
     $user->generateVerifyToken();
     $user->generateAuthKey();
     $user->save();
     return $user;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * The method create user.
  * @param User $user
  * @param CmgFile $avatar
  * @return User
  */
 public static function create($user, $avatar = null)
 {
     // Set Attributes
     $user->registeredAt = DateUtil::getDateTime();
     $user->status = User::STATUS_NEW;
     // Generate Tokens
     $user->generateVerifyToken();
     $user->generateAuthKey();
     if (isset($avatar)) {
         // Save Avatar
         FileService::saveImage($avatar, ['model' => $user, 'attribute' => 'avatarId']);
     }
     // Create User
     $user->save();
     // Add to mailing list
     if ($user->newsletter) {
         NewsletterMemberService::create($user->email, $user->getName());
     }
     return $user;
 }