コード例 #1
0
 public static function boot()
 {
     parent::boot();
     VerifiedEmail::creating(function ($email) {
         $email->verify_token = str_random(64);
         $email->expires_at = Carbon::now()->addHour();
     });
 }
コード例 #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('user', function ($attribute, $value, $parameters) {
         if (VerifiedEmail::where('email', $value)->count() > 0 || User::where('username', $value)->count() > 0) {
             return true;
         }
         return false;
     });
 }
コード例 #3
0
ファイル: Registrar.php プロジェクト: wunderfactory/weinform
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $bDaySplit = explode('.', $data['birth_date']);
     $user = User::create(['username' => $data['name'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'password' => bcrypt($data['password']), 'birth_date' => Carbon::createFromDate($bDaySplit[2], $bDaySplit[1], $bDaySplit[0]), 'gender' => $data['gender']]);
     $email = VerifiedEmail::create(['email' => $data['email'], 'user_id' => $user->id]);
     Bus::dispatch(new EmailCreated($email));
     Bus::dispatch(new CreateSettings($user));
     Bus::dispatch(new CreateVerifiedPhoneNumber($user, $data['phonefield'], $data['phonefield_country']));
     return $user;
 }
コード例 #4
0
ファイル: Email.php プロジェクト: wunderfactory/weinform
 public function verifyEmail($token)
 {
     if ($token) {
         $email = VerifiedEmail::where('verify_token', $token)->first();
         if ($email && Carbon::now() <= $email->expires_at) {
             $email->verified_at = Carbon::now();
             $email->verified = true;
             $email->save();
             return $email;
         }
     }
     return false;
 }
コード例 #5
0
ファイル: Loginar.php プロジェクト: wunderfactory/weinform
 /**
  * Login a user instance after a valid input.
  *
  * @param  array $data
  * @return boolean
  */
 public function login(array $data)
 {
     $user = User::where('username', $data['username'])->first();
     $email = VerifiedEmail::where('email', $data['username'])->first();
     if ($user && password_verify($data['password'], $user->password) || $email && password_verify($data['password'], $email->user->password)) {
         if ($user) {
             Auth::login($user, array_has($data, 'remember'));
         } else {
             Auth::login($email->user, array_has($data, 'remember'));
         }
         return true;
     }
     return false;
 }