-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
40 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php namespace AdamWathan\EloquentOAuth; | ||
|
||
class EloquentIdentityStore implements IdentityStore | ||
{ | ||
public function getByProvider($provider, $providerUser) | ||
{ | ||
return OAuthIdentity::where('provider', $provider) | ||
->where('provider_user_id', $providerUser->id) | ||
->first(); | ||
} | ||
|
||
public function flush($user, $provider) | ||
{ | ||
OAuthIdentity::where('user_id', $user->getKey()) | ||
->where('provider', $provider) | ||
->delete(); | ||
} | ||
|
||
public function store($identity) | ||
{ | ||
$identity->save(); | ||
} | ||
|
||
public function userExists($provider, $providerUser) | ||
{ | ||
return (bool) $this->getByProvider($provider, $providerUser); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,9 @@ | ||
<?php namespace AdamWathan\EloquentOAuth; | ||
|
||
class IdentityStore | ||
interface IdentityStore | ||
{ | ||
public function getByProvider($provider, $providerUser) | ||
{ | ||
return OAuthIdentity::where('provider', $provider) | ||
->where('provider_user_id', $providerUser->id) | ||
->first(); | ||
} | ||
|
||
public function flush($user, $provider) | ||
{ | ||
OAuthIdentity::where('user_id', $user->getKey()) | ||
->where('provider', $provider) | ||
->delete(); | ||
} | ||
|
||
public function store($identity) | ||
{ | ||
$identity->save(); | ||
} | ||
|
||
public function userExists($provider, $providerUser) | ||
{ | ||
return (bool) $this->getByProvider($provider, $providerUser); | ||
} | ||
public function getByProvider($provider, $providerUser); | ||
public function flush($user, $provider); | ||
public function store($identity); | ||
public function userExists($provider, $providerUser); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters