@@ -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 | $peopleLink = $user->getPeople()->getLink()->first(); |
166 | 170 | |
167 | - if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
|
168 | - return $peopleLink->getCompany(); |
|
171 | + if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) { |
|
172 | + return $peopleLink->getCompany(); |
|
173 | + } |
|
169 | 174 | } |
170 | 175 | |
171 | 176 | private function getCompanyId(User $user) |
@@ -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 |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | public function __construct(private EntityManagerInterface $manager, private UserPasswordEncoderInterface $encoder) {} |
13 | 13 | public function changePassword(User $user, $password) |
14 | 14 | { |
15 | - if (!$this->getPermission()) |
|
16 | - throw new Exception("You should not pass!!!", 301); |
|
15 | + if (!$this->getPermission()) { |
|
16 | + throw new Exception("You should not pass!!!", 301); |
|
17 | + } |
|
17 | 18 | |
18 | 19 | $user->setHash( |
19 | 20 | $this->encoder->encodePassword($user, $password) |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | |
27 | 28 | public function createUser($people_id, $username, $password) |
28 | 29 | { |
29 | - if (!$this->getPermission()) |
|
30 | - throw new Exception("You should not pass!!!", 301); |
|
30 | + if (!$this->getPermission()) { |
|
31 | + throw new Exception("You should not pass!!!", 301); |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $user = new User(); |
33 | 35 | $user->setPeople($this->manager->getRepository(User::class)->find($people_id)); |