@@ -28,13 +28,13 @@ |
||
28 | 28 | public function updatePassword(string $email, string $password): ?User |
29 | 29 | { |
30 | 30 | if ($user = $this->findOneByEmail($email)) { |
31 | - $user->setPassword($password); |
|
31 | + $user->setPassword($password); |
|
32 | 32 | |
33 | - $this->getEntityManager()->persist($user); |
|
33 | + $this->getEntityManager()->persist($user); |
|
34 | 34 | |
35 | - $this->getEntityManager()->flush(); |
|
35 | + $this->getEntityManager()->flush(); |
|
36 | 36 | |
37 | - return $user; |
|
37 | + return $user; |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 |
@@ -95,10 +95,11 @@ discard block |
||
95 | 95 | ->findOneBy([ |
96 | 96 | 'username' => $ownerDetails->getEmail(), |
97 | 97 | ]); |
98 | - if (!$user) |
|
99 | - |
|
98 | + if (!$user) { |
|
99 | + |
|
100 | 100 | |
101 | 101 | $user = $this->createUser($ownerDetails); |
102 | + } |
|
102 | 103 | |
103 | 104 | |
104 | 105 | |
@@ -122,20 +123,23 @@ discard block |
||
122 | 123 | try { |
123 | 124 | |
124 | 125 | |
125 | - if ($request->get('code')) |
|
126 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
126 | + if ($request->get('code')) { |
|
127 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
127 | 128 | 'code' => $request->get('code') |
128 | 129 | ]); |
130 | + } |
|
129 | 131 | |
130 | - if ($request->get('access_token')) |
|
131 | - $token = new AccessToken([ |
|
132 | + if ($request->get('access_token')) { |
|
133 | + $token = new AccessToken([ |
|
132 | 134 | 'access_token' => $request->get('access_token'), |
133 | 135 | ]); |
136 | + } |
|
134 | 137 | |
135 | - if ($request->get('code')) |
|
136 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
138 | + if ($request->get('code')) { |
|
139 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
137 | 140 | 'code' => $request->get('code') |
138 | 141 | ]); |
142 | + } |
|
139 | 143 | |
140 | 144 | |
141 | 145 | $data = $this->discoveryUser($token); |
@@ -164,8 +168,9 @@ discard block |
||
164 | 168 | { |
165 | 169 | $peopleEmployee = $user->getPeople()->getPeopleCompany()->first(); |
166 | 170 | |
167 | - if ($peopleEmployee !== false && $peopleEmployee->getCompany() instanceof People) |
|
168 | - return $peopleEmployee->getCompany(); |
|
171 | + if ($peopleEmployee !== false && $peopleEmployee->getCompany() instanceof People) { |
|
172 | + return $peopleEmployee->getCompany(); |
|
173 | + } |
|
169 | 174 | } |
170 | 175 | |
171 | 176 | private function getCompanyId(User $user) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @var Request |
28 | 28 | */ |
29 | - private $request = null; |
|
29 | + private $request = null; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Security |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | $user = new User(); |
111 | 111 | $user->setUsername($payload['username']); |
112 | - $user->setHash ($this->encoder->encodePassword($user, $payload['password'])); |
|
113 | - $user->setPeople ($company); |
|
112 | + $user->setHash($this->encoder->encodePassword($user, $payload['password'])); |
|
113 | + $user->setPeople($company); |
|
114 | 114 | |
115 | 115 | $this->manager->persist($user); |
116 | 116 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | throw new \InvalidArgumentException('Deve existir pelo menos um usuário'); |
145 | 145 | } |
146 | 146 | |
147 | - $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $company]); |
|
147 | + $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $company]); |
|
148 | 148 | if (!$user instanceof User) { |
149 | 149 | throw new \InvalidArgumentException('Person user was not found'); |
150 | 150 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | private function getUsers(Person $person, ?array $payload = null): array |
168 | 168 | { |
169 | 169 | $members = []; |
170 | - $company = $this->manager->getRepository(People::class )->find($person->getId()); |
|
170 | + $company = $this->manager->getRepository(People::class)->find($person->getId()); |
|
171 | 171 | $users = $this->manager->getRepository(User::class)->findBy(['people' => $company]); |
172 | 172 | |
173 | 173 | foreach ($users as $user) { |
@@ -122,8 +122,9 @@ discard block |
||
122 | 122 | ]; |
123 | 123 | |
124 | 124 | } catch (\Exception $e) { |
125 | - if ($this->manager->getConnection()->isTransactionActive()) |
|
126 | - $this->manager->getConnection()->rollBack(); |
|
125 | + if ($this->manager->getConnection()->isTransactionActive()) { |
|
126 | + $this->manager->getConnection()->rollBack(); |
|
127 | + } |
|
127 | 128 | |
128 | 129 | throw new \InvalidArgumentException($e->getMessage()); |
129 | 130 | } |
@@ -157,8 +158,9 @@ discard block |
||
157 | 158 | return true; |
158 | 159 | |
159 | 160 | } catch (\Exception $e) { |
160 | - if ($this->manager->getConnection()->isTransactionActive()) |
|
161 | - $this->manager->getConnection()->rollBack(); |
|
161 | + if ($this->manager->getConnection()->isTransactionActive()) { |
|
162 | + $this->manager->getConnection()->rollBack(); |
|
163 | + } |
|
162 | 164 | |
163 | 165 | throw new \InvalidArgumentException($e->getMessage()); |
164 | 166 | } |