@@ -27,10 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | $user = $this->getUser(); |
29 | 29 | |
30 | - if ($user === null) |
|
31 | - return $this->json([ |
|
30 | + if ($user === null) { |
|
31 | + return $this->json([ |
|
32 | 32 | 'error' => 'User not found' |
33 | 33 | ]); |
34 | + } |
|
34 | 35 | |
35 | 36 | // get contact data from user |
36 | 37 | |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | $code = ''; |
39 | 40 | $number = ''; |
40 | 41 | |
41 | - if ($user->getPeople()->getEmail()->count() > 0) |
|
42 | - $email = $user->getPeople()->getEmail()->first()->getEmail(); |
|
42 | + if ($user->getPeople()->getEmail()->count() > 0) { |
|
43 | + $email = $user->getPeople()->getEmail()->first()->getEmail(); |
|
44 | + } |
|
43 | 45 | |
44 | 46 | if ($user->getPeople()->getPhone()->count() > 0) { |
45 | 47 | $phone = $user->getPeople()->getPhone()->first(); |
@@ -65,10 +67,9 @@ discard block |
||
65 | 67 | { |
66 | 68 | $realName = 'John Doe'; |
67 | 69 | |
68 | - if ($people->getPeopleType() == 'J') |
|
69 | - $realName = $people->getAlias(); |
|
70 | - |
|
71 | - else { |
|
70 | + if ($people->getPeopleType() == 'J') { |
|
71 | + $realName = $people->getAlias(); |
|
72 | + } else { |
|
72 | 73 | if ($people->getPeopleType() == 'F') { |
73 | 74 | $realName = $people->getName(); |
74 | 75 | $realName .= ' ' . $people->getAlias(); |
@@ -82,8 +83,9 @@ discard block |
||
82 | 83 | private function getCompany(User $user): ?People |
83 | 84 | { |
84 | 85 | $peopleLink = $this->manager->getRepository(People::class)->getPeopleLinks($user->getPeople(), 'employee', 1); |
85 | - if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
|
86 | - return $peopleLink->getCompany(); |
|
86 | + if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) { |
|
87 | + return $peopleLink->getCompany(); |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | |
89 | 91 | private function getCompanyId(User $user): ?int |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | public function __construct(private EntityManagerInterface $manager, private UserPasswordEncoderInterface $encoder) {} |
14 | 14 | public function changePassword(User $user, $password) |
15 | 15 | { |
16 | - if (!$this->getPermission()) |
|
17 | - throw new Exception("You should not pass!!!", 301); |
|
16 | + if (!$this->getPermission()) { |
|
17 | + throw new Exception("You should not pass!!!", 301); |
|
18 | + } |
|
18 | 19 | |
19 | 20 | $user->setHash( |
20 | 21 | $this->encoder->encodePassword($user, $password) |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | |
28 | 29 | public function changeApiKey(User $user) |
29 | 30 | { |
30 | - if (!$this->getPermission()) |
|
31 | - throw new Exception("You should not pass!!!", 301); |
|
31 | + if (!$this->getPermission()) { |
|
32 | + throw new Exception("You should not pass!!!", 301); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $user->generateApiKey(); |
34 | 36 | |
@@ -39,8 +41,9 @@ discard block |
||
39 | 41 | |
40 | 42 | public function createUser(People $people, $username, $password) |
41 | 43 | { |
42 | - if (!$this->getPermission()) |
|
43 | - throw new Exception("You should not pass!!!", 301); |
|
44 | + if (!$this->getPermission()) { |
|
45 | + throw new Exception("You should not pass!!!", 301); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | $user = new User(); |
46 | 49 | $user->setPeople($people); |
@@ -97,8 +97,9 @@ discard block |
||
97 | 97 | 'username' => $ownerDetails->getEmail(), |
98 | 98 | ]); |
99 | 99 | |
100 | - if (!$user) |
|
101 | - $user = $this->createUser($ownerDetails); |
|
100 | + if (!$user) { |
|
101 | + $user = $this->createUser($ownerDetails); |
|
102 | + } |
|
102 | 103 | |
103 | 104 | $data = [ |
104 | 105 | 'id' => $user->getPeople()->getId(), |
@@ -121,20 +122,23 @@ discard block |
||
121 | 122 | try { |
122 | 123 | |
123 | 124 | |
124 | - if ($request->get('code')) |
|
125 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
125 | + if ($request->get('code')) { |
|
126 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
126 | 127 | 'code' => $request->get('code') |
127 | 128 | ]); |
129 | + } |
|
128 | 130 | |
129 | - if ($request->get('access_token')) |
|
130 | - $token = new AccessToken([ |
|
131 | + if ($request->get('access_token')) { |
|
132 | + $token = new AccessToken([ |
|
131 | 133 | 'access_token' => $request->get('access_token'), |
132 | 134 | ]); |
135 | + } |
|
133 | 136 | |
134 | - if ($request->get('code')) |
|
135 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
137 | + if ($request->get('code')) { |
|
138 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
136 | 139 | 'code' => $request->get('code') |
137 | 140 | ]); |
141 | + } |
|
138 | 142 | |
139 | 143 | |
140 | 144 | $data = $this->discoveryUser($token); |
@@ -163,8 +167,9 @@ discard block |
||
163 | 167 | { |
164 | 168 | $peopleLink = $user->getPeople()->getLink()->first(); |
165 | 169 | |
166 | - if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
|
167 | - return $peopleLink->getCompany(); |
|
170 | + if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) { |
|
171 | + return $peopleLink->getCompany(); |
|
172 | + } |
|
168 | 173 | } |
169 | 174 | |
170 | 175 | private function getCompanyId(User $user) |