public static authenticate ( string $providerId, array $params = null ) | ||
$providerId | string | ID of the provider |
$params | array | Params |
public static function authenticate($providerId, $params = null)
{
Hybrid_Logger::info("Enter Hybrid_Auth::authenticate( {$providerId} )");
if (!Hybrid_Auth::storage()->get("hauth_session.{$providerId}.is_logged_in")) {
// if user not connected to $providerId then try setup a new adapter and start the login process for this provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( {$providerId} ), User not connected to the provider. Try to authenticate..");
$provider_adapter = Hybrid_Auth::setup($providerId, $params);
$provider_adapter->login();
} else {
// else, then return the adapter instance for the given provider
Hybrid_Logger::info("Hybrid_Auth::authenticate( {$providerId} ), User is already connected to this provider. Return the adapter instance.");
return Hybrid_Auth::getAdapter($providerId);
}
}
public function getGoogleLogin($auth = NULL) { if ($auth == 'auth') { Hybrid_Endpoint::process(); } try { $oauth = new Hybrid_Auth(app_path() . '/config/google_auth.php'); $provider = $oauth->authenticate('Google'); $profile = $provider->getUserProfile(); } catch (exception $e) { return $e->getMessage(); } if ($user = User::where('email', '=', $profile->email)->first()) { Auth::login($user, true); return Redirect::intended('/'); } return App::make('frontend\\UserController')->doSignUp(array('email' => $profile->email, 'login' => $profile->identifier, 'password' => "pass1234", 'f_name' => $profile->firstName, 'l_name' => $profile->lastName)); }