/**
  * 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;
     });
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('user', function ($value) {
         return User::where('username', $value)->first();
     });
     $router->bind('faq', function ($value) {
         return Question::where('id', $value)->first();
     });
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 public function getFacebookReturn()
 {
     if (Facebook::getSessionFromRedirect()) {
         if (Facebook::foundFacebookUser()) {
             if (Facebook::getFacebookUser()->user) {
                 if (User::where('id', Facebook::getFacebookUser()->user->id)->count() > 0) {
                     Facebook::getFriends();
                     Auth::login(Facebook::getFacebookUser()->user);
                     return redirect()->action('UsersController@getOverview', Auth::user()->username);
                 }
                 return redirect()->to('auth/login')->withErrors(['user' => Lang::get('auth/facebook.email_verified')]);
             } else {
                 $this->session->put(['facebookUser_id' => Facebook::getFacebookUser()->id]);
                 return redirect('auth/register')->withInput(Facebook::createInput())->with(array('fbid' => Facebook::getFacebookUser()->id));
             }
         } else {
             dd("wtf");
             App::abort(404);
         }
     } else {
         return $this->getFacebook();
     }
     return $this->getFacebook();
 }
Esempio n. 6
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     return User::findOrFail($id);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $user, $shipment
  * @return Response
  */
 public function destroy($user, $shipment)
 {
     $user = User::findOrFail($user);
 }