@@ -4,9 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace SWP\Bundle\CoreBundle\Controller; |
| 6 | 6 | |
| 7 | -use KnpU\OAuth2ClientBundle\Client\ClientRegistry; |
|
| 8 | 7 | use Symfony\Component\HttpFoundation\Request; |
| 9 | -use League\OAuth2\Client\Provider\Exception\IdentityProviderException; |
|
| 10 | 8 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 11 | 9 | use Symfony\Component\Routing\Annotation\Route; |
| 12 | 10 | |
@@ -4,10 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace SWP\Bundle\CoreBundle\Security\Authenticator; |
| 6 | 6 | |
| 7 | -use Doctrine\ORM\EntityManagerInterface; |
|
| 8 | -use SWP\Bundle\CoreBundle\Model\UserInterface as CoreUserInterface; |
|
| 9 | -use SWP\Bundle\CoreBundle\Security\Provider\UserProvider; |
|
| 10 | -use Symfony\Component\Security\Core\User\UserInterface; |
|
| 11 | 7 | use KnpU\OAuth2ClientBundle\Security\Authenticator\SocialAuthenticator; |
| 12 | 8 | use KnpU\OAuth2ClientBundle\Client\ClientRegistry; |
| 13 | 9 | use Symfony\Component\HttpFoundation\Request; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function supports(Request $request) |
| 52 | 52 | { |
| 53 | - if(!$this->security->getUser() || ($request->query->get('code') && $request->get('state'))) { |
|
| 53 | + if (!$this->security->getUser() || ($request->query->get('code') && $request->get('state'))) { |
|
| 54 | 54 | return true; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | $oauthEmail = $oauthUser->getEmail(); |
| 80 | 80 | $oauthId = $oauthUser->getId(); |
| 81 | 81 | |
| 82 | - if(!$oauthUser) { |
|
| 82 | + if (!$oauthUser) { |
|
| 83 | 83 | return null; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Is there an existing user with the same oauth id? |
| 87 | 87 | $user = $userProvider->findOneByExternalId($oauthId); |
| 88 | - if($user) { |
|
| 89 | - if($user->getEmail() !== $oauthEmail) { |
|
| 88 | + if ($user) { |
|
| 89 | + if ($user->getEmail() !== $oauthEmail) { |
|
| 90 | 90 | // If the email has changed for the user, update it here as well |
| 91 | 91 | $user->setEmail($oauthEmail); |
| 92 | 92 | $user->setUsername($oauthEmail); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | // Is there an existing user with the same email address? |
| 100 | 100 | $user = $userProvider->findOneByEmail($oauthEmail); |
| 101 | - if($user) { |
|
| 101 | + if ($user) { |
|
| 102 | 102 | return $user; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function getAccessToken($grant, $options = []) { |
| 25 | - if(!isset($this->access_token)) { |
|
| 25 | + if (!isset($this->access_token)) { |
|
| 26 | 26 | $this->access_token = parent::getAccessToken($grant, $options); |
| 27 | 27 | } |
| 28 | 28 | return $this->access_token; |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | public function getBaseAuthorizationUrl() |
| 32 | 32 | { |
| 33 | - return $this->base_url . '/authorize'; |
|
| 33 | + return $this->base_url.'/authorize'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function getBaseAccessTokenUrl(array $params) |
| 37 | 37 | { |
| 38 | - return $this->base_url . '/oauth/token'; |
|
| 38 | + return $this->base_url.'/oauth/token'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
| 42 | 42 | { |
| 43 | - return $this->base_url . '/userinfo'; |
|
| 43 | + return $this->base_url.'/userinfo'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | protected function getDefaultScopes() |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function checkResponse(ResponseInterface $response, $data) |
| 52 | 52 | { |
| 53 | - if($response->getStatusCode() >= 400) { |
|
| 53 | + if ($response->getStatusCode() >= 400) { |
|
| 54 | 54 | return new IdentityProviderException( |
| 55 | 55 | $response->getReasonPhrase(), |
| 56 | 56 | $response->getStatusCode(), |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | protected function getAuthorizationHeaders($token = null) |
| 72 | 72 | { |
| 73 | - if($token) { |
|
| 73 | + if ($token) { |
|
| 74 | 74 | return [ |
| 75 | - 'Authorization' => 'Bearer ' . $token |
|
| 75 | + 'Authorization' => 'Bearer '.$token |
|
| 76 | 76 | ]; |
| 77 | 77 | } else { |
| 78 | 78 | return []; |