示例#1
0
 public function testOtherUnsubscribe()
 {
     $user = \Unflr\Eloquents\User::find(1);
     $this->testGuy->sendGET('/other/unsubscribe/' . $user->unsubscribe_guid);
     $this->testGuy->seeInDatabase('users', ['id' => 1, 'receives_notifs' => 'f']);
     $this->testGuy->seeInCurrentUrl('/thanks/' . $user->referral_code);
 }
示例#2
0
文件: User.php 项目: stanmay/unflare
 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;
 }
示例#3
0
文件: Root.php 项目: stanmay/unflare
 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;
 }