Completed
Pull Request — master (#904)
by Paweł
11:37
created
src/SWP/Bundle/CoreBundle/Controller/ExternalOauthController.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,9 +4,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
SWP/Bundle/CoreBundle/Security/Authenticator/ExternalOauthAuthenticator.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -4,10 +4,6 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/SWP/Bundle/UserBundle/Model/UserInterface.php 1 patch
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -29,6 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
59 62
 
60 63
     /**
61 64
      * @param string $externalId
65
+     * @return void
62 66
      */
63 67
     public function setExternalId(string $externalId);
64 68
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Security/Provider/ExternalOauthProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 [];
Please login to merge, or discard this patch.