@@ -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 | } |
@@ -24,8 +24,8 @@ |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | try { |
27 | - $payload = json_decode($request->getContent()); |
|
28 | - $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | + $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
29 | 29 | |
30 | 30 | $user = $this->service->createUser( |
31 | 31 | $people, |
@@ -13,43 +13,43 @@ |
||
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()); |
|
28 | - $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | + $people = $this->manager->getRepository(People::class)->find($payload->people); |
|
29 | 29 | |
30 | - $user = $this->service->createUser( |
|
30 | + $user = $this->service->createUser( |
|
31 | 31 | $people, |
32 | 32 | $payload->username, |
33 | 33 | $payload->password |
34 | - ); |
|
34 | + ); |
|
35 | 35 | |
36 | - return new JsonResponse( |
|
36 | + return new JsonResponse( |
|
37 | 37 | $this->hydratorService->item( |
38 | - User::class, |
|
39 | - $user->getId(), |
|
40 | - "user:read" |
|
38 | + User::class, |
|
39 | + $user->getId(), |
|
40 | + "user:read" |
|
41 | 41 | ) |
42 | - ); |
|
42 | + ); |
|
43 | 43 | } catch (\Exception $e) { |
44 | 44 | |
45 | - return new JsonResponse([ |
|
45 | + return new JsonResponse([ |
|
46 | 46 | 'response' => [ |
47 | - 'data' => [], |
|
48 | - 'count' => 0, |
|
49 | - 'error' => $e->getMessage(), |
|
50 | - 'success' => false, |
|
47 | + 'data' => [], |
|
48 | + 'count' => 0, |
|
49 | + 'error' => $e->getMessage(), |
|
50 | + 'success' => false, |
|
51 | 51 | ], |
52 | - ], 500); |
|
52 | + ], 500); |
|
53 | + } |
|
53 | 54 | } |
54 | - } |
|
55 | 55 | } |
@@ -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 |
@@ -14,25 +14,25 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - public function __construct( |
|
17 | + public function __construct( |
|
18 | 18 | private PeopleRoleService $roleService, |
19 | 19 | private EntityManagerInterface $manager, |
20 | 20 | protected UserService $userService |
21 | - ) {} |
|
21 | + ) {} |
|
22 | 22 | |
23 | - public function __invoke(Request $request) |
|
24 | - { |
|
23 | + public function __invoke(Request $request) |
|
24 | + { |
|
25 | 25 | /** |
26 | 26 | * @var \ControleOnline\Entity\User |
27 | 27 | */ |
28 | 28 | $user = $this->getUser(); |
29 | 29 | |
30 | 30 | if ($user === null) |
31 | - return $this->json([ |
|
31 | + return $this->json([ |
|
32 | 32 | 'error' => 'User not found' |
33 | - ]); |
|
33 | + ]); |
|
34 | 34 | |
35 | 35 | return $this->json($this->userService->getUserSession($user)); |
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | } |
@@ -27,10 +27,11 @@ |
||
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 | return $this->json($this->userService->getUserSession($user)); |
36 | 37 |
@@ -24,8 +24,8 @@ |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | try { |
27 | - $payload = json_decode($request->getContent()); |
|
28 | - $people = $this->service->discoveryPeople($payload->email, $payload->name); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | + $people = $this->service->discoveryPeople($payload->email, $payload->name); |
|
29 | 29 | |
30 | 30 | $user = $this->service->getUserSession($this->service->createUser( |
31 | 31 | $people, |
@@ -13,43 +13,43 @@ |
||
13 | 13 | class CreateAccountAction |
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()); |
|
28 | - $people = $this->service->discoveryPeople($payload->email, $payload->name); |
|
27 | + $payload = json_decode($request->getContent()); |
|
28 | + $people = $this->service->discoveryPeople($payload->email, $payload->name); |
|
29 | 29 | |
30 | - $user = $this->service->getUserSession($this->service->createUser( |
|
30 | + $user = $this->service->getUserSession($this->service->createUser( |
|
31 | 31 | $people, |
32 | 32 | $payload->email, |
33 | 33 | $payload->password |
34 | - )); |
|
34 | + )); |
|
35 | 35 | |
36 | - return new JsonResponse([ |
|
36 | + return new JsonResponse([ |
|
37 | 37 | 'response' => [ |
38 | - 'data' => $user, |
|
39 | - 'count' => 1, |
|
40 | - 'success' => true, |
|
38 | + 'data' => $user, |
|
39 | + 'count' => 1, |
|
40 | + 'success' => true, |
|
41 | 41 | ], |
42 | - ]); |
|
42 | + ]); |
|
43 | 43 | } catch (\Exception $e) { |
44 | 44 | |
45 | - return new JsonResponse([ |
|
45 | + return new JsonResponse([ |
|
46 | 46 | 'response' => [ |
47 | - 'data' => [], |
|
48 | - 'count' => 0, |
|
49 | - 'error' => $e->getMessage(), |
|
50 | - 'success' => false, |
|
47 | + 'data' => [], |
|
48 | + 'count' => 0, |
|
49 | + 'error' => $e->getMessage(), |
|
50 | + 'success' => false, |
|
51 | 51 | ], |
52 | - ], 500); |
|
52 | + ], 500); |
|
53 | + } |
|
53 | 54 | } |
54 | - } |
|
55 | 55 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | |
39 | 39 | return new Passport( |
40 | - new UserBadge($apiToken, function ($apiToken) { |
|
40 | + new UserBadge($apiToken, function($apiToken) { |
|
41 | 41 | $user = $this->em->getRepository(User::class)->findOneBy(['apiKey' => $apiToken]); |
42 | 42 | if (null === $user) |
43 | 43 | throw new CustomUserMessageAuthenticationException('Invalid API token'); |
@@ -32,15 +32,17 @@ |
||
32 | 32 | public function authenticate(Request $request): Passport |
33 | 33 | { |
34 | 34 | $apiToken = $this->getKey($request); |
35 | - if (null === $apiToken) |
|
36 | - throw new CustomUserMessageAuthenticationException('No API token provided'); |
|
35 | + if (null === $apiToken) { |
|
36 | + throw new CustomUserMessageAuthenticationException('No API token provided'); |
|
37 | + } |
|
37 | 38 | |
38 | 39 | |
39 | 40 | return new Passport( |
40 | 41 | new UserBadge($apiToken, function ($apiToken) { |
41 | 42 | $user = $this->em->getRepository(User::class)->findOneBy(['apiKey' => $apiToken]); |
42 | - if (null === $user) |
|
43 | - throw new CustomUserMessageAuthenticationException('Invalid API token'); |
|
43 | + if (null === $user) { |
|
44 | + throw new CustomUserMessageAuthenticationException('Invalid API token'); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return $user; |
46 | 48 | }), |