/** * Display register new user form. * * @return \Illuminate\View\View */ public function create() { $variables = []; if (class_exists('Ipunkt\\SocialAuth\\SocialAuth')) { if (\Ipunkt\SocialAuth\SocialAuth::hasRegistration()) { $variables['registerInfo'] = \Ipunkt\SocialAuth\SocialAuth::getRegistration(); } } // Renew registerInfo in the session for the store call. Session::reflash(); $view = View::make('auth::register', $variables); return $view; }
/** * Login into a social-auth account intending to register a new user with it * It is considered successful if the user logs into the social-auth account and the account is not yet attached to * a different Account on this system. * * If Successful it will redirect back to the register page as set in the config and flash a new * registerInfo => ProfileRegisterInfo object to the register page. * On successful registration it is necessary to call registerInfo->success(newUser) to actualy attach the social-auth * user to the newly registered user * * @see ProfileRegisterInfo * @param $provider_name * @return \Illuminate\Http\RedirectResponse|null */ public function register($provider_name) { $response = null; $profile = null; $route = Config::get('social-auth::register_route'); $identifier = $this->auth($provider_name, $profile); if (!$this->checkRegistered($provider_name, $identifier)) { $register_info = App::make('Ipunkt\\SocialAuth\\RegisterInfo'); /** * @var RegisterInfo $register_info */ $register_info->setProvider($provider_name); SocialAuth::setRegistration($register_info); $response = Redirect::route($route); } else { $response = Redirect::route($route)->withErrors(['message' => trans('social-auth::user.account already registered', ['accountname' => $profile->displayName]), ['accountname' => $profile->displayName]]); } return $response; }
/** * @return ProviderInterface|null */ protected function searchProviderByName($providerName) { $provider = null; foreach (SocialAuth::getConnectedProviders() as $connected_provider) { if ($providerName == $connected_provider->getIdentifier()) { $provider = $connected_provider; break; } } return $provider; }