@@ -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 |
@@ -34,20 +34,23 @@ |
||
34 | 34 | try { |
35 | 35 | |
36 | 36 | |
37 | - if ($request->get('code')) |
|
38 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
37 | + if ($request->get('code')) { |
|
38 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
39 | 39 | 'code' => $request->get('code') |
40 | 40 | ]); |
41 | + } |
|
41 | 42 | |
42 | - if ($request->get('access_token')) |
|
43 | - $token = new AccessToken([ |
|
43 | + if ($request->get('access_token')) { |
|
44 | + $token = new AccessToken([ |
|
44 | 45 | 'access_token' => $request->get('access_token'), |
45 | 46 | ]); |
47 | + } |
|
46 | 48 | |
47 | - if ($request->get('code')) |
|
48 | - $token = $this->provider->getAccessToken('authorization_code', [ |
|
49 | + if ($request->get('code')) { |
|
50 | + $token = $this->provider->getAccessToken('authorization_code', [ |
|
49 | 51 | 'code' => $request->get('code') |
50 | 52 | ]); |
53 | + } |
|
51 | 54 | |
52 | 55 | $ownerDetails = $this->provider->getResourceOwner($token); |
53 | 56 |
@@ -26,10 +26,11 @@ |
||
26 | 26 | try { |
27 | 27 | $payload = json_decode($request->getContent()); |
28 | 28 | |
29 | - if ($payload->people) |
|
30 | - $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
31 | - else |
|
32 | - $people = $this->service->discoveryPeople($payload->username, $payload->firstName, $payload->lastName); |
|
29 | + if ($payload->people) { |
|
30 | + $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
31 | + } else { |
|
32 | + $people = $this->service->discoveryPeople($payload->username, $payload->firstName, $payload->lastName); |
|
33 | + } |
|
33 | 34 | |
34 | 35 | $user = $this->service->createUser( |
35 | 36 | $people, |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | public function __construct(private EntityManagerInterface $manager, private UserPasswordEncoderInterface $encoder) {} |
16 | 16 | public function changePassword(User $user, $password) |
17 | 17 | { |
18 | - if (!$this->getPermission()) |
|
19 | - throw new Exception("You should not pass!!!", 301); |
|
18 | + if (!$this->getPermission()) { |
|
19 | + throw new Exception("You should not pass!!!", 301); |
|
20 | + } |
|
20 | 21 | |
21 | 22 | $user->setHash( |
22 | 23 | $this->encoder->encodePassword($user, $password) |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | public function changeApiKey(User $user) |
31 | 32 | { |
32 | - if (!$this->getPermission()) |
|
33 | - throw new Exception("You should not pass!!!", 301); |
|
33 | + if (!$this->getPermission()) { |
|
34 | + throw new Exception("You should not pass!!!", 301); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | $user->generateApiKey(); |
36 | 38 | |
@@ -51,8 +53,9 @@ discard block |
||
51 | 53 | |
52 | 54 | $people = $this->discoveryPeople($email, $firstName, $lastName); |
53 | 55 | |
54 | - if (!$user) |
|
55 | - $user = $this->createUser($people, $email, $password); |
|
56 | + if (!$user) { |
|
57 | + $user = $this->createUser($people, $email, $password); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | return $user; |
58 | 61 | } |
@@ -93,16 +96,18 @@ discard block |
||
93 | 96 | |
94 | 97 | public function createUser(People $people, $username, $password) |
95 | 98 | { |
96 | - if (!$this->getPermission()) |
|
97 | - throw new Exception("You should not pass!!!", 301); |
|
99 | + if (!$this->getPermission()) { |
|
100 | + throw new Exception("You should not pass!!!", 301); |
|
101 | + } |
|
98 | 102 | |
99 | 103 | $user = $this->manager->getRepository(User::class) |
100 | 104 | ->findOneBy([ |
101 | 105 | 'username' => $username, |
102 | 106 | ]); |
103 | 107 | |
104 | - if ($username) |
|
105 | - throw new Exception("User already exists", 301); |
|
108 | + if ($username) { |
|
109 | + throw new Exception("User already exists", 301); |
|
110 | + } |
|
106 | 111 | |
107 | 112 | $user = new User(); |
108 | 113 | $user->setPeople($people); |
@@ -119,8 +124,9 @@ discard block |
||
119 | 124 | { |
120 | 125 | $peopleLink = $user->getPeople()->getLink()->first(); |
121 | 126 | |
122 | - if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
|
123 | - return $peopleLink->getCompany(); |
|
127 | + if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) { |
|
128 | + return $peopleLink->getCompany(); |
|
129 | + } |
|
124 | 130 | } |
125 | 131 | |
126 | 132 | public function getCompanyId(User $user) |