Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Update LaravelKinveyAuthServiceProvider.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jhariani committed Oct 20, 2014
1 parent ff82cef commit e466c65
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/GovTribe/LaravelKinvey/LaravelKinveyAuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ public function registerEvents()
//Store the Kinvey auth token in the user's session, and clear it on logout.
Event::listen('auth.login', function($user)
{
Session::put('kinvey', $user->_kmd['authtoken']);
// User logged in via an OAuth provider, we need to log them into Kinvey.
if (!isset($user->_kmd['authtoken']))
{
$credentials = [
'_socialIdentity' => $user->_socialIdentity,
];

$kinveyResponse = $this->app['kinvey']->loginOAuth($credentials);
$kinveyAuthToken = $kinveyResponse['_kmd']['authtoken'];
}
// User logged in directly via Kinvey.
else $kinveyAuthToken = $user->_kmd['authtoken'];

Session::put('kinvey', $kinveyAuthToken);
});

Event::listen('auth.logout', function($user)
Expand Down

0 comments on commit e466c65

Please sign in to comment.