@@ -29,6 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @param string $about |
| 32 | + * @return void |
|
| 32 | 33 | */ |
| 33 | 34 | public function setAbout(string $about); |
| 34 | 35 | |
@@ -39,6 +40,7 @@ discard block |
||
| 39 | 40 | |
| 40 | 41 | /** |
| 41 | 42 | * @param string $firstName |
| 43 | + * @return void |
|
| 42 | 44 | */ |
| 43 | 45 | public function setFirstName(string $firstName); |
| 44 | 46 | |
@@ -49,6 +51,7 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | /** |
| 51 | 53 | * @param string $lastName |
| 54 | + * @return void |
|
| 52 | 55 | */ |
| 53 | 56 | public function setLastName(string $lastName); |
| 54 | 57 | |
@@ -59,6 +62,7 @@ discard block |
||
| 59 | 62 | |
| 60 | 63 | /** |
| 61 | 64 | * @param string $externalId |
| 65 | + * @return void |
|
| 62 | 66 | */ |
| 63 | 67 | public function setExternalId(string $externalId); |
| 64 | 68 | } |
@@ -4,9 +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 | 7 | use Symfony\Component\Security\Core\User\UserInterface; |
| 11 | 8 | use KnpU\OAuth2ClientBundle\Security\Authenticator\SocialAuthenticator; |
| 12 | 9 | use KnpU\OAuth2ClientBundle\Client\ClientRegistry; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function supports(Request $request): bool |
| 55 | 55 | { |
| 56 | - if(!$this->security->getUser() || ($request->query->get('code') && $request->get('state'))) { |
|
| 56 | + if (!$this->security->getUser() || ($request->query->get('code') && $request->get('state'))) { |
|
| 57 | 57 | return true; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | $oauthEmail = $oauthUser->getEmail(); |
| 83 | 83 | $oauthId = $oauthUser->getId(); |
| 84 | 84 | |
| 85 | - if(!$oauthUser) { |
|
| 85 | + if (!$oauthUser) { |
|
| 86 | 86 | return null; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Is there an existing user with the same oauth id? |
| 90 | 90 | $user = $userProvider->findOneByExternalId($oauthId); |
| 91 | - if($user) { |
|
| 92 | - if($user->getEmail() !== $oauthEmail) { |
|
| 91 | + if ($user) { |
|
| 92 | + if ($user->getEmail() !== $oauthEmail) { |
|
| 93 | 93 | // If the email has changed for the user, update it here as well |
| 94 | 94 | $user->setEmail($oauthEmail); |
| 95 | 95 | $user->setUsername($oauthEmail); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // Is there an existing user with the same email address? |
| 103 | 103 | $user = $userProvider->findOneByEmail($oauthEmail); |
| 104 | - if($user) { |
|
| 104 | + if ($user) { |
|
| 105 | 105 | return $user; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function getAccessToken($grant, array $options = []): AccessToken |
| 25 | 25 | { |
| 26 | - if(!isset($this->access_token)) { |
|
| 26 | + if (!isset($this->access_token)) { |
|
| 27 | 27 | $this->access_token = parent::getAccessToken($grant, $options); |
| 28 | 28 | } |
| 29 | 29 | return $this->access_token; |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function getBaseAuthorizationUrl(): string |
| 33 | 33 | { |
| 34 | - return $this->base_url . '/authorize'; |
|
| 34 | + return $this->base_url.'/authorize'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function getBaseAccessTokenUrl(array $params): string |
| 38 | 38 | { |
| 39 | - return $this->base_url . '/oauth/token'; |
|
| 39 | + return $this->base_url.'/oauth/token'; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function getResourceOwnerDetailsUrl(AccessToken $token): string |
| 43 | 43 | { |
| 44 | - return $this->base_url . '/userinfo'; |
|
| 44 | + return $this->base_url.'/userinfo'; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | protected function getDefaultScopes(): string |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | protected function checkResponse(ResponseInterface $response, $data): void |
| 53 | 53 | { |
| 54 | - if($response->getStatusCode() >= 400) { |
|
| 54 | + if ($response->getStatusCode() >= 400) { |
|
| 55 | 55 | throw new IdentityProviderException( |
| 56 | 56 | $response->getReasonPhrase(), |
| 57 | 57 | $response->getStatusCode(), |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | protected function getAuthorizationHeaders($token = null): array |
| 73 | 73 | { |
| 74 | - if($token) { |
|
| 74 | + if ($token) { |
|
| 75 | 75 | return [ |
| 76 | - 'Authorization' => 'Bearer ' . $token |
|
| 76 | + 'Authorization' => 'Bearer '.$token |
|
| 77 | 77 | ]; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -4,12 +4,8 @@ |
||
| 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 | 8 | use Symfony\Component\HttpFoundation\Response; |
| 10 | -use Symfony\Component\HttpFoundation\RedirectResponse; |
|
| 11 | -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
|
| 12 | -use League\OAuth2\Client\Provider\Exception\IdentityProviderException; |
|
| 13 | 9 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 14 | 10 | use Symfony\Component\Routing\Annotation\Route; |
| 15 | 11 | |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | public function connectCheckAction(Request $request): Response |
| 37 | 37 | { |
| 38 | 38 | // If we didn't log in, something went wrong. Throw an exception! |
| 39 | - if(!$this->getUser()) { |
|
| 40 | - $response = $this->render('bundles/TwigBundle/Exception/error403.html.twig'); |
|
| 39 | + if (!$this->getUser()) { |
|
| 40 | + $response = $this->render('bundles/TwigBundle/Exception/error403.html.twig'); |
|
| 41 | 41 | $response->setStatusCode(403); |
| 42 | 42 | return $response; |
| 43 | 43 | } |