Completed
Push — master ( 8f2b16...c80f65 )
by Marcel
03:24
created
src/Menu/Builder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         ])
54 54
             ->setAttribute('icon', 'fas fa-shield-alt');
55 55
 
56
-        if($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
56
+        if ($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
57 57
             $menu->addChild('users.label', [
58 58
                 'route' => 'users'
59 59
             ])
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             ->setExtra('menu-container', '#submenu')
94 94
             ->setExtra('pull-right', true);
95 95
 
96
-        if($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
96
+        if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
97 97
             $menu->addChild('user_types.label', [
98 98
                 'route' => 'user_types'
99 99
             ])
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             ])
105 105
                 ->setAttribute('icon', 'fas fa-user-tag');
106 106
 
107
-            if($this->adAuthEnabled === true) {
107
+            if ($this->adAuthEnabled === true) {
108 108
                 $menu->addChild('ad_sync_options.label', [
109 109
                     'route' => 'ad_sync_options'
110 110
                 ])
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 
163 163
         $user = $this->tokenStorage->getToken()->getUser();
164 164
 
165
-        if(!$user instanceof User) {
165
+        if (!$user instanceof User) {
166 166
             return $menu;
167 167
         }
168 168
 
169 169
         $label = 'dark_mode.enable';
170 170
         $icon = 'far fa-moon';
171 171
 
172
-        if($this->darkModeManager->isDarkModeEnabled()) {
172
+        if ($this->darkModeManager->isDarkModeEnabled()) {
173 173
             $label = 'dark_mode.disable';
174 174
             $icon = 'far fa-sun';
175 175
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $token = $this->tokenStorage->getToken();
208 208
         $user = $token->getUser();
209 209
 
210
-        if($user instanceof User) {
210
+        if ($user instanceof User) {
211 211
             $menu = $root->addChild('services', [
212 212
                 'label' => ''
213 213
             ])
Please login to merge, or discard this patch.
src/Security/UserAuthenticator.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     public function getUser($credentials, UserProviderInterface $userProvider) {
103 103
         $token = new CsrfToken('authenticate', $credentials['csrf_token']);
104 104
 
105
-        if(!$this->csrfTokenManager->isTokenValid($token)) {
105
+        if (!$this->csrfTokenManager->isTokenValid($token)) {
106 106
             throw new InvalidCsrfTokenException();
107 107
         }
108 108
 
@@ -110,18 +110,18 @@  discard block
 block discarded – undo
110 110
             /** @var User $user */
111 111
             $user = $userProvider->loadUserByUsername($credentials['username']);
112 112
 
113
-            if($user->isProvisioned() === false) {
113
+            if ($user->isProvisioned() === false) {
114 114
                 throw new CustomUserMessageAuthenticationException('not_provisioned');
115 115
             }
116 116
 
117
-            if($user instanceof ActiveDirectoryUser) {
117
+            if ($user instanceof ActiveDirectoryUser) {
118 118
                 $user = $this->authenticateUsingActiveDirectory(new Credentials($credentials['username'], $credentials['password']), $user);
119 119
             }
120
-        } catch(UsernameNotFoundException $e) {
120
+        } catch (UsernameNotFoundException $e) {
121 121
             $user = $this->authenticateUsingActiveDirectory(new Credentials($credentials['username'], $credentials['password']));
122 122
         }
123 123
 
124
-        if($user === null) {
124
+        if ($user === null) {
125 125
             throw new CustomUserMessageAuthenticationException('invalid_credentials');
126 126
         }
127 127
 
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function checkCredentials($credentials, UserInterface $user) {
135 135
         return $this->encoder->isPasswordValid($user, $credentials['password'])
136
-            && ((!$user instanceof User) || $user->isDeleted() === false);          // Important: check if user was deleted
136
+            && ((!$user instanceof User) || $user->isDeleted() === false); // Important: check if user was deleted
137 137
     }
138 138
 
139 139
     /**
140 140
      * @inheritDoc
141 141
      */
142 142
     public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) {
143
-        if($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
143
+        if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
144 144
             return new RedirectResponse($targetPath);
145 145
         }
146 146
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
     }
149 149
 
150 150
     protected function authenticateUsingActiveDirectory(Credentials $credentials, ActiveDirectoryUser $adUser = null) {
151
-        if($this->isActiveDirectoryEnabled !== true) {
151
+        if ($this->isActiveDirectoryEnabled !== true) {
152 152
             return $adUser;
153 153
         }
154 154
 
155 155
         $upnSuffix = substr($credentials->getUsername(), strpos($credentials->getUsername(), '@') + 1);
156 156
         $upnSuffixes = array_map(function(ActiveDirectoryUpnSuffix $suffix) { return $suffix->getSuffix(); }, $this->upnSuffixRepository->findAll());
157 157
 
158
-        if(count($upnSuffixes) > 0 && !in_array($upnSuffix, $upnSuffixes)) {
158
+        if (count($upnSuffixes) > 0 && !in_array($upnSuffix, $upnSuffixes)) {
159 159
             $this->logger->debug(sprintf('UPN-Suffix "%s" is not enabled for AD sync.', $upnSuffix));
160 160
             return $adUser;
161 161
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
             /** @var AuthenticationResponse $response */
165 165
             $response = $this->adAuth->authenticate($credentials);
166 166
 
167
-            if($response->isSuccess() !== true) {
167
+            if ($response->isSuccess() !== true) {
168 168
                 $this->logger
169 169
                     ->notice(sprintf('Failed to authenticate "%s" using Active Directory', $credentials->getUsername()));
170 170
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
             $info = $this->transformResponse($response);
176 176
 
177
-            if($this->userCreator->canCreateUser($info)) {
177
+            if ($this->userCreator->canCreateUser($info)) {
178 178
                 $user = $this->userCreator->createUser($info, $adUser);
179 179
 
180 180
                 $user->setPassword($this->encoder->encodePassword($user, $credentials->getPassword()));
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 
189 189
                 throw new CustomUserMessageAuthenticationException('not_allowed');
190 190
             }
191
-        } catch(SocketException $e) {
191
+        } catch (SocketException $e) {
192 192
             $this->logger
193 193
                 ->critical('Authentication server is not available');
194 194
 
195 195
             throw new CustomUserMessageAuthenticationException('server_unavailable');
196
-        } catch(\Exception $e) {
196
+        } catch (\Exception $e) {
197 197
             $this->logger->critical(
198 198
                 'Authentication failed', [
199 199
                     'exception' => $e
Please login to merge, or discard this patch.
src/EventSubscriber/ApiExceptionSubscriber.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public function onKernelException(ExceptionEvent $event) {
30 30
         $request = $event->getRequest();
31 31
 
32
-        if(!in_array(static::JsonContentType, $request->getAcceptableContentTypes())) {
32
+        if (!in_array(static::JsonContentType, $request->getAcceptableContentTypes())) {
33 33
             return;
34 34
         }
35 35
 
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
         $code = Response::HTTP_INTERNAL_SERVER_ERROR;
38 38
 
39 39
         // Case 1: general HttpException (Authorization/Authentication) or BadRequest
40
-        if($throwable instanceof HttpException) {
40
+        if ($throwable instanceof HttpException) {
41 41
             $code = $throwable->getStatusCode();
42 42
             $message = new ErrorResponse($throwable->getMessage(), get_class($throwable));
43
-        } else if($throwable instanceof ValidationFailedException) { // Case 2: validation failed
43
+        } else if ($throwable instanceof ValidationFailedException) { // Case 2: validation failed
44 44
             $code = Response::HTTP_BAD_REQUEST;
45 45
 
46
-            $violations = [ ];
47
-            foreach($throwable->getConstraintViolations() as $violation) {
48
-                $violations[] = new Violation($violation->getPropertyPath(), (string)$violation->getMessage());
46
+            $violations = [];
47
+            foreach ($throwable->getConstraintViolations() as $violation) {
48
+                $violations[] = new Violation($violation->getPropertyPath(), (string) $violation->getMessage());
49 49
             }
50 50
 
51 51
             $message = new ViolationListResponse($violations);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         }
62 62
 
63 63
         $validStatusCodes = array_keys(Response::$statusTexts);
64
-        if(!in_array($code, $validStatusCodes)) {
64
+        if (!in_array($code, $validStatusCodes)) {
65 65
             $code = Response::HTTP_INTERNAL_SERVER_ERROR;
66 66
         }
67 67
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,8 @@  discard block
 block discarded – undo
40 40
         if($throwable instanceof HttpException) {
41 41
             $code = $throwable->getStatusCode();
42 42
             $message = new ErrorResponse($throwable->getMessage(), get_class($throwable));
43
-        } else if($throwable instanceof ValidationFailedException) { // Case 2: validation failed
43
+        } else if($throwable instanceof ValidationFailedException) {
44
+// Case 2: validation failed
44 45
             $code = Response::HTTP_BAD_REQUEST;
45 46
 
46 47
             $violations = [ ];
@@ -49,7 +50,8 @@  discard block
 block discarded – undo
49 50
             }
50 51
 
51 52
             $message = new ViolationListResponse($violations);
52
-        } else { // Case 3: General error
53
+        } else {
54
+// Case 3: General error
53 55
             $message = new ErrorResponse(
54 56
                 'An unknown error occured.',
55 57
                 get_class($throwable)
Please login to merge, or discard this patch.
src/Command/ProvisionUserCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
         $users = $this->userRepository->findNextNonProvisionedUsers($this->numberOfUsers);
40 40
 
41
-        foreach($users as $user) {
41
+        foreach ($users as $user) {
42 42
             $user->setPassword(
43 43
                 $this->passwordEncoder->encodePassword($user, $user->getPassword())
44 44
             );
Please login to merge, or discard this patch.
src/Migrations/Version20200709105141.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@
 block discarded – undo
10 10
 /**
11 11
  * Auto-generated Migration: Please modify to your needs!
12 12
  */
13
-final class Version20200709105141 extends AbstractMigration
14
-{
13
+final class Version20200709105141 extends AbstractMigration {
15 14
     public function getDescription() : string
16 15
     {
17 16
         return '';
Please login to merge, or discard this patch.
src/Validator/UniqueUsernameValidator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@
 block discarded – undo
21 21
      * @inheritDoc
22 22
      */
23 23
     public function validate($value, Constraint $constraint) {
24
-        if(!$constraint instanceof UniqueUsername) {
24
+        if (!$constraint instanceof UniqueUsername) {
25 25
             throw new UnexpectedTypeException($constraint, UniqueUsername::class);
26 26
         }
27 27
 
28
-        if(!is_string($value)) {
28
+        if (!is_string($value)) {
29 29
             throw new UnexpectedTypeException($constraint, 'string');
30 30
         }
31 31
 
32 32
         $user = $this->userRepository->findOneByUsername($value);
33 33
 
34
-        if($user !== null && $this->matchesType($user, $constraint->type) === false) {
34
+        if ($user !== null && $this->matchesType($user, $constraint->type) === false) {
35 35
             $this->context
36 36
                 ->buildViolation($constraint->message)
37 37
                 ->addViolation();
Please login to merge, or discard this patch.