middleware('guest', ['only' => ['getLogin', 'postLogin', 'getRegister']]); $this->socialAuthService = $socialAuthService; } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6', ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]); } /** * Show the application registration form. * * @return \Illuminate\Http\Response */ public function getRegister() { $socialDrivers = $this->socialAuthService->getActiveDrivers(); return view('auth.register', ['socialDrivers' => $socialDrivers]); } /** * Show the application login form. * * @return \Illuminate\Http\Response */ public function getLogin() { if (view()->exists('auth.authenticate')) { return view('auth.authenticate'); } $socialDrivers = $this->socialAuthService->getActiveDrivers(); return view('auth.login', ['socialDrivers' => $socialDrivers]); } /** * Redirect to the relevant social site. * @param $socialDriver * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function getSocialLogin($socialDriver) { return $this->socialAuthService->startLogIn($socialDriver); } /** * The callback for social login services. * * @param $socialDriver * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector * @throws SocialSignInException */ public function socialCallback($socialDriver) { return $this->socialAuthService->handleCallback($socialDriver); } /** * Detach a social account from a user. * @param $socialDriver * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function detachSocialAccount($socialDriver) { return $this->socialAuthService->detachSocialAccount($socialDriver); } }