/** * 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(); }); }
/** * 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; }
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(); }