@@ -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 |
@@ -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,22 +13,22 @@ discard block |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - public function __construct( |
|
16 | + public function __construct( |
|
17 | 17 | private PeopleRoleService $roleService, |
18 | 18 | private EntityManagerInterface $manager, |
19 | - ) {} |
|
19 | + ) {} |
|
20 | 20 | |
21 | - public function __invoke(Request $request) |
|
22 | - { |
|
21 | + public function __invoke(Request $request) |
|
22 | + { |
|
23 | 23 | /** |
24 | 24 | * @var \ControleOnline\Entity\User |
25 | 25 | */ |
26 | 26 | $user = $this->getUser(); |
27 | 27 | |
28 | 28 | if ($user === null) |
29 | - return $this->json([ |
|
29 | + return $this->json([ |
|
30 | 30 | 'error' => 'User not found' |
31 | - ]); |
|
31 | + ]); |
|
32 | 32 | |
33 | 33 | // get contact data from user |
34 | 34 | |
@@ -37,57 +37,57 @@ discard block |
||
37 | 37 | $number = ''; |
38 | 38 | |
39 | 39 | if ($user->getPeople()->getEmail()->count() > 0) |
40 | - $email = $user->getPeople()->getEmail()->first()->getEmail(); |
|
40 | + $email = $user->getPeople()->getEmail()->first()->getEmail(); |
|
41 | 41 | |
42 | 42 | if ($user->getPeople()->getPhone()->count() > 0) { |
43 | - $phone = $user->getPeople()->getPhone()->first(); |
|
44 | - $code = $phone->getDdd(); |
|
45 | - $number = $phone->getPhone(); |
|
43 | + $phone = $user->getPeople()->getPhone()->first(); |
|
44 | + $code = $phone->getDdd(); |
|
45 | + $number = $phone->getPhone(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return $this->json([ |
49 | - 'id' => $user->getPeople()->getId(), |
|
50 | - 'username' => $user->getUsername(), |
|
51 | - 'roles' => $user->getRoles(), |
|
52 | - 'api_key' => $user->getApiKey(), |
|
53 | - 'people' => $user->getPeople()->getId(), |
|
54 | - 'mycompany' => $this->getCompanyId($user), |
|
55 | - 'realname' => $this->getUserRealName($user->getPeople()), |
|
56 | - 'avatar' => $user->getPeople()->getImage() ? '/files/' . $user->getPeople()->getImage()->getId() . '/download' : null, |
|
57 | - 'email' => $email, |
|
58 | - 'phone' => sprintf('%s%s', $code, $number), |
|
59 | - 'active' => (int) $user->getPeople()->getEnabled(), |
|
49 | + 'id' => $user->getPeople()->getId(), |
|
50 | + 'username' => $user->getUsername(), |
|
51 | + 'roles' => $user->getRoles(), |
|
52 | + 'api_key' => $user->getApiKey(), |
|
53 | + 'people' => $user->getPeople()->getId(), |
|
54 | + 'mycompany' => $this->getCompanyId($user), |
|
55 | + 'realname' => $this->getUserRealName($user->getPeople()), |
|
56 | + 'avatar' => $user->getPeople()->getImage() ? '/files/' . $user->getPeople()->getImage()->getId() . '/download' : null, |
|
57 | + 'email' => $email, |
|
58 | + 'phone' => sprintf('%s%s', $code, $number), |
|
59 | + 'active' => (int) $user->getPeople()->getEnabled(), |
|
60 | 60 | ]); |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | - private function getUserRealName(People $people): string |
|
64 | - { |
|
63 | + private function getUserRealName(People $people): string |
|
64 | + { |
|
65 | 65 | $realName = 'John Doe'; |
66 | 66 | |
67 | 67 | if ($people->getPeopleType() == 'J') |
68 | - $realName = $people->getAlias(); |
|
68 | + $realName = $people->getAlias(); |
|
69 | 69 | |
70 | 70 | else { |
71 | - if ($people->getPeopleType() == 'F') { |
|
71 | + if ($people->getPeopleType() == 'F') { |
|
72 | 72 | $realName = $people->getName(); |
73 | 73 | $realName .= ' ' . $people->getAlias(); |
74 | 74 | $realName = trim($realName); |
75 | - } |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $realName; |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - private function getCompany(User $user): ?People |
|
82 | - { |
|
81 | + private function getCompany(User $user): ?People |
|
82 | + { |
|
83 | 83 | $peopleLink = $this->manager->getRepository(People::class)->getPeopleLinks($user->getPeople(), 'employee', 1); |
84 | 84 | if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
85 | - return $peopleLink->getCompany(); |
|
86 | - } |
|
85 | + return $peopleLink->getCompany(); |
|
86 | + } |
|
87 | 87 | |
88 | - private function getCompanyId(User $user): ?int |
|
89 | - { |
|
88 | + private function getCompanyId(User $user): ?int |
|
89 | + { |
|
90 | 90 | $company = $this->getCompany($user); |
91 | 91 | return $company ? $company->getId() : null; |
92 | - } |
|
92 | + } |
|
93 | 93 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $this->provider = new Instagram([ |
28 | 28 | 'clientId' => $this->clientId, |
29 | 29 | 'clientSecret' => $this->clientSecret, |
30 | - 'redirectUri' => 'https://' .$this->domainService->getMainDomain() . '/oauth/instagram/return', |
|
30 | + 'redirectUri' => 'https://' . $this->domainService->getMainDomain() . '/oauth/instagram/return', |
|
31 | 31 | //'hostedDomain' => 'example.com', // optional; used to restrict access to users on your G Suite/Instagram Apps for Business accounts |
32 | 32 | ]); |
33 | 33 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | try { |
26 | - $payload = json_decode($request->getContent()); |
|
26 | + $payload = json_decode($request->getContent()); |
|
27 | 27 | |
28 | 28 | $user = $this->service->changePassword($data, $payload->password); |
29 | 29 |
@@ -12,38 +12,38 @@ |
||
12 | 12 | class ChangePasswordAction |
13 | 13 | { |
14 | 14 | |
15 | - public function __construct( |
|
15 | + public function __construct( |
|
16 | 16 | private EntityManagerInterface $manager, |
17 | 17 | private UserService $service, |
18 | 18 | private HydratorService $hydratorService |
19 | 19 | |
20 | - ) {} |
|
20 | + ) {} |
|
21 | 21 | |
22 | - public function __invoke(User $data, Request $request) |
|
23 | - { |
|
22 | + public function __invoke(User $data, Request $request) |
|
23 | + { |
|
24 | 24 | |
25 | 25 | try { |
26 | - $payload = json_decode($request->getContent()); |
|
26 | + $payload = json_decode($request->getContent()); |
|
27 | 27 | |
28 | - $user = $this->service->changePassword($data, $payload->password); |
|
28 | + $user = $this->service->changePassword($data, $payload->password); |
|
29 | 29 | |
30 | - return new JsonResponse( |
|
30 | + return new JsonResponse( |
|
31 | 31 | $this->hydratorService->item( |
32 | - User::class, |
|
33 | - $user->getId(), |
|
34 | - "user:read" |
|
32 | + User::class, |
|
33 | + $user->getId(), |
|
34 | + "user:read" |
|
35 | 35 | ) |
36 | - ); |
|
36 | + ); |
|
37 | 37 | } catch (\Exception $e) { |
38 | 38 | |
39 | - return new JsonResponse([ |
|
39 | + return new JsonResponse([ |
|
40 | 40 | 'response' => [ |
41 | - 'data' => [], |
|
42 | - 'count' => 0, |
|
43 | - 'error' => $e->getMessage(), |
|
44 | - 'success' => false, |
|
41 | + 'data' => [], |
|
42 | + 'count' => 0, |
|
43 | + 'error' => $e->getMessage(), |
|
44 | + 'success' => false, |
|
45 | 45 | ], |
46 | - ], 500); |
|
46 | + ], 500); |
|
47 | + } |
|
47 | 48 | } |
48 | - } |
|
49 | 49 | } |
@@ -11,37 +11,37 @@ |
||
11 | 11 | class ChangeApiKeyAction |
12 | 12 | { |
13 | 13 | |
14 | - public function __construct( |
|
14 | + public function __construct( |
|
15 | 15 | private EntityManagerInterface $manager, |
16 | 16 | private UserService $service, |
17 | 17 | private HydratorService $hydratorService |
18 | 18 | |
19 | - ) {} |
|
19 | + ) {} |
|
20 | 20 | |
21 | - public function __invoke(User $data) |
|
22 | - { |
|
21 | + public function __invoke(User $data) |
|
22 | + { |
|
23 | 23 | |
24 | 24 | try { |
25 | 25 | |
26 | - $user = $this->service->changeApiKey($data); |
|
26 | + $user = $this->service->changeApiKey($data); |
|
27 | 27 | |
28 | - return new JsonResponse( |
|
28 | + return new JsonResponse( |
|
29 | 29 | $this->hydratorService->item( |
30 | - User::class, |
|
31 | - $user->getId(), |
|
32 | - "user:read" |
|
30 | + User::class, |
|
31 | + $user->getId(), |
|
32 | + "user:read" |
|
33 | 33 | ) |
34 | - ); |
|
34 | + ); |
|
35 | 35 | } catch (\Exception $e) { |
36 | 36 | |
37 | - return new JsonResponse([ |
|
37 | + return new JsonResponse([ |
|
38 | 38 | 'response' => [ |
39 | - 'data' => [], |
|
40 | - 'count' => 0, |
|
41 | - 'error' => $e->getMessage(), |
|
42 | - 'success' => false, |
|
39 | + 'data' => [], |
|
40 | + 'count' => 0, |
|
41 | + 'error' => $e->getMessage(), |
|
42 | + 'success' => false, |
|
43 | 43 | ], |
44 | - ], 500); |
|
44 | + ], 500); |
|
45 | + } |
|
45 | 46 | } |
46 | - } |
|
47 | 47 | } |
@@ -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 |
@@ -13,47 +13,47 @@ |
||
13 | 13 | class CreateUserAction |
14 | 14 | { |
15 | 15 | |
16 | - public function __construct( |
|
16 | + public function __construct( |
|
17 | 17 | private EntityManagerInterface $manager, |
18 | 18 | private UserService $service, |
19 | 19 | private HydratorService $hydratorService |
20 | 20 | |
21 | - ) {} |
|
21 | + ) {} |
|
22 | 22 | |
23 | - public function __invoke(Request $request) |
|
24 | - { |
|
23 | + public function __invoke(Request $request) |
|
24 | + { |
|
25 | 25 | |
26 | 26 | try { |
27 | - $payload = json_decode($request->getContent()); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | 28 | |
29 | - if ($payload->people) |
|
29 | + if ($payload->people) |
|
30 | 30 | $people = $this->manager->getRepository(People::class)->find($payload->people); |
31 | - else |
|
31 | + else |
|
32 | 32 | $people = $this->service->discoveryPeople($payload->username, $payload->firstName, $payload->lastName); |
33 | 33 | |
34 | - $user = $this->service->createUser( |
|
34 | + $user = $this->service->createUser( |
|
35 | 35 | $people, |
36 | 36 | $payload->username, |
37 | 37 | $payload->password |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | - return new JsonResponse( |
|
40 | + return new JsonResponse( |
|
41 | 41 | $this->hydratorService->item( |
42 | - User::class, |
|
43 | - $user->getId(), |
|
44 | - "user:read" |
|
42 | + User::class, |
|
43 | + $user->getId(), |
|
44 | + "user:read" |
|
45 | 45 | ) |
46 | - ); |
|
46 | + ); |
|
47 | 47 | } catch (\Exception $e) { |
48 | 48 | |
49 | - return new JsonResponse([ |
|
49 | + return new JsonResponse([ |
|
50 | 50 | 'response' => [ |
51 | - 'data' => [], |
|
52 | - 'count' => 0, |
|
53 | - 'error' => $e->getMessage(), |
|
54 | - 'success' => false, |
|
51 | + 'data' => [], |
|
52 | + 'count' => 0, |
|
53 | + 'error' => $e->getMessage(), |
|
54 | + 'success' => false, |
|
55 | 55 | ], |
56 | - ], 500); |
|
56 | + ], 500); |
|
57 | + } |
|
57 | 58 | } |
58 | - } |
|
59 | 59 | } |
@@ -24,12 +24,12 @@ |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | try { |
27 | - $payload = json_decode($request->getContent()); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | 28 | |
29 | 29 | if ($payload->people) |
30 | - $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
30 | + $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
31 | 31 | else |
32 | - $people = $this->service->discoveryPeople($payload->username, $payload->firstName, $payload->lastName); |
|
32 | + $people = $this->service->discoveryPeople($payload->username, $payload->firstName, $payload->lastName); |
|
33 | 33 | |
34 | 34 | $user = $this->service->createUser( |
35 | 35 | $people, |
@@ -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, |
@@ -12,97 +12,97 @@ discard block |
||
12 | 12 | |
13 | 13 | class UserService |
14 | 14 | { |
15 | - public function __construct(private EntityManagerInterface $manager, private UserPasswordEncoderInterface $encoder) {} |
|
16 | - public function changePassword(User $user, $password) |
|
17 | - { |
|
15 | + public function __construct(private EntityManagerInterface $manager, private UserPasswordEncoderInterface $encoder) {} |
|
16 | + public function changePassword(User $user, $password) |
|
17 | + { |
|
18 | 18 | if (!$this->getPermission()) |
19 | - throw new Exception("You should not pass!!!", 301); |
|
19 | + throw new Exception("You should not pass!!!", 301); |
|
20 | 20 | |
21 | 21 | $user->setHash( |
22 | - $this->encoder->encodePassword($user, $password) |
|
22 | + $this->encoder->encodePassword($user, $password) |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $this->manager->persist($user); |
26 | 26 | $this->manager->flush(); |
27 | 27 | return $user; |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - public function changeApiKey(User $user) |
|
31 | - { |
|
30 | + public function changeApiKey(User $user) |
|
31 | + { |
|
32 | 32 | if (!$this->getPermission()) |
33 | - throw new Exception("You should not pass!!!", 301); |
|
33 | + throw new Exception("You should not pass!!!", 301); |
|
34 | 34 | |
35 | 35 | $user->generateApiKey(); |
36 | 36 | |
37 | 37 | $this->manager->persist($user); |
38 | 38 | $this->manager->flush(); |
39 | 39 | return $user; |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - public function discoveryUser($email, $password, $firstName, $lastName) |
|
44 | - { |
|
43 | + public function discoveryUser($email, $password, $firstName, $lastName) |
|
44 | + { |
|
45 | 45 | |
46 | 46 | $user = $this->manager->getRepository(User::class) |
47 | - ->findOneBy([ |
|
47 | + ->findOneBy([ |
|
48 | 48 | 'username' => $email, |
49 | - ]); |
|
49 | + ]); |
|
50 | 50 | |
51 | 51 | |
52 | 52 | $people = $this->discoveryPeople($email, $firstName, $lastName); |
53 | 53 | |
54 | 54 | if (!$user) |
55 | - $user = $this->createUser($people, $email, $password); |
|
55 | + $user = $this->createUser($people, $email, $password); |
|
56 | 56 | |
57 | 57 | return $user; |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - public function discoveryPeople($email, $firstName = '', $lastName = '') |
|
61 | - { |
|
60 | + public function discoveryPeople($email, $firstName = '', $lastName = '') |
|
61 | + { |
|
62 | 62 | $email = $this->manager->getRepository(Email::class) |
63 | - ->findOneBy([ |
|
63 | + ->findOneBy([ |
|
64 | 64 | 'email' => $email, |
65 | - ]); |
|
65 | + ]); |
|
66 | 66 | if ($email) { |
67 | - $people = $email->getPeople(); |
|
67 | + $people = $email->getPeople(); |
|
68 | 68 | } else { |
69 | - $email = new Email(); |
|
70 | - $email->setEmail($email); |
|
71 | - $this->manager->persist($email); |
|
69 | + $email = new Email(); |
|
70 | + $email->setEmail($email); |
|
71 | + $this->manager->persist($email); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | if (!$people) { |
75 | 75 | |
76 | - $lang = $this->manager->getRepository(Language::class)->findOneBy(['language' => 'pt-BR']); |
|
77 | - $people = new People(); |
|
78 | - $people->setAlias($firstName); |
|
79 | - $people->setName($lastName); |
|
80 | - $people->setLanguage($lang); |
|
81 | - //$people->setBilling(0); |
|
82 | - //$people->setBillingDays('daily'); |
|
83 | - //$people->setPaymentTerm(1); |
|
84 | - //$people->setIcms(0); |
|
85 | - $email->setPeople($people); |
|
86 | - $this->manager->persist($email); |
|
76 | + $lang = $this->manager->getRepository(Language::class)->findOneBy(['language' => 'pt-BR']); |
|
77 | + $people = new People(); |
|
78 | + $people->setAlias($firstName); |
|
79 | + $people->setName($lastName); |
|
80 | + $people->setLanguage($lang); |
|
81 | + //$people->setBilling(0); |
|
82 | + //$people->setBillingDays('daily'); |
|
83 | + //$people->setPaymentTerm(1); |
|
84 | + //$people->setIcms(0); |
|
85 | + $email->setPeople($people); |
|
86 | + $this->manager->persist($email); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $this->manager->persist($people); |
90 | 90 | $this->manager->flush(); |
91 | 91 | return $people; |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - public function createUser(People $people, $username, $password) |
|
95 | - { |
|
94 | + public function createUser(People $people, $username, $password) |
|
95 | + { |
|
96 | 96 | if (!$this->getPermission()) |
97 | - throw new Exception("You should not pass!!!", 301); |
|
97 | + throw new Exception("You should not pass!!!", 301); |
|
98 | 98 | |
99 | 99 | $user = $this->manager->getRepository(User::class) |
100 | - ->findOneBy([ |
|
100 | + ->findOneBy([ |
|
101 | 101 | 'username' => $username, |
102 | - ]); |
|
102 | + ]); |
|
103 | 103 | |
104 | 104 | if ($username) |
105 | - throw new Exception("User already exists", 301); |
|
105 | + throw new Exception("User already exists", 301); |
|
106 | 106 | |
107 | 107 | $user = new User(); |
108 | 108 | $user->setPeople($people); |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | $this->manager->persist($user); |
113 | 113 | $this->manager->flush(); |
114 | 114 | return $user; |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - public function getCompany(User $user) |
|
119 | - { |
|
118 | + public function getCompany(User $user) |
|
119 | + { |
|
120 | 120 | $peopleLink = $user->getPeople()->getLink()->first(); |
121 | 121 | |
122 | 122 | if ($peopleLink !== false && $peopleLink->getCompany() instanceof People) |
123 | - return $peopleLink->getCompany(); |
|
124 | - } |
|
123 | + return $peopleLink->getCompany(); |
|
124 | + } |
|
125 | 125 | |
126 | - public function getCompanyId(User $user) |
|
127 | - { |
|
126 | + public function getCompanyId(User $user) |
|
127 | + { |
|
128 | 128 | $company = $this->getCompany($user); |
129 | 129 | return $company ? $company->getId() : null; |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @todo arrumar |
|
134 | - */ |
|
135 | - private function getPermission() |
|
136 | - { |
|
132 | + /** |
|
133 | + * @todo arrumar |
|
134 | + */ |
|
135 | + private function getPermission() |
|
136 | + { |
|
137 | 137 | return true; |
138 | - } |
|
138 | + } |
|
139 | 139 | } |
@@ -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) |