Exemplo n.º 1
0
 public function register($email, $ipAddress, $referrerCode = null, $isMobile = null, $extra = null)
 {
     if (Eloquents\User::where('email', $email)->first()) {
         throw new \Unflr\Exceptions\AlreadyRegistered();
     }
     $this->email = $email;
     $this->orm = Eloquents\User::create(['email' => $email, 'ipaddress' => $ipAddress, 'referral_code' => $this->createReferralCode(), 'referred_by' => $referrerCode, 'unsubscribe_guid' => Str::random(24), 'has_mobile_registered' => $isMobile, 'coupon' => Str::random(10)]);
     // referrer notif
     if ($referrerCode) {
         $referrer = (new User())->findBy('referral_code', $referrerCode);
         $referrer->exists() and $referrer->addReferralSuccess();
     }
     $this->sendWelcomeEmail();
     return $this;
 }
Exemplo n.º 2
0
 protected function checkEmail($email)
 {
     // required / spam
     $rules = ['email' => 'required|email'];
     if (!defined('TESTING')) {
         $rules = array_merge($rules, ['my_name' => 'honeypot', 'my_time' => 'required|honeytime:2']);
     }
     $validator = \Validator::make(Input::get(), $rules);
     if ($validator->fails()) {
         throw new \ValidationException($validator);
     }
     // throwable emails
     if (!(new EmailChecker())->isValid($email)) {
         throw new RegistrationFailed(__('Please use a real address!'));
     }
     // check ip
     if (\Unflr\Eloquents\User::where('ipaddress', \Request::getClientIp())->count() >= 2) {
         throw new RegistrationFailed(__('We like your enthusiasm but try sharing this with your friends!'));
     }
     return $this;
 }