@@ -13,6 +13,6 @@ |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | -Route::get('/test', function (Request $request) { |
|
16 | +Route::get('/test', function(Request $request) { |
|
17 | 17 | return response()->json('welcome to the api'); |
18 | 18 | }); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $this->resolver->setDefaultConnection($this->getDatabase()); |
36 | 36 | |
37 | - Model::unguarded(function () { |
|
37 | + Model::unguarded(function() { |
|
38 | 38 | foreach ($this->getSeeders() as $seeder) { |
39 | 39 | $seeder = $this->laravel->make($seeder); |
40 | 40 | $seeder->__invoke(); |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | { |
49 | 49 | $this->service = $this->laravel->make(BootstrapRegistrarService::class); |
50 | 50 | |
51 | - return $this->service->getSeeders() ?? []; |
|
51 | + return $this->service->getSeeders() ?? [ ]; |
|
52 | 52 | } |
53 | 53 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | use Modules\User\Entities\User; |
4 | 4 | |
5 | -$factory->define(User::class, function (Faker\Generator $faker) { |
|
5 | +$factory->define(User::class, function(Faker\Generator $faker) { |
|
6 | 6 | return [ |
7 | 7 | 'auth0_id' => null, |
8 | 8 | 'name' => $faker->name, |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | | 'Auth0\Login\Auth0Controller@callback' |
38 | 38 | | |
39 | 39 | */ |
40 | - 'redirect_uri' => env('APP_URL') . '/auth0/callback', |
|
40 | + 'redirect_uri' => env('APP_URL').'/auth0/callback', |
|
41 | 41 | |
42 | 42 | /* |
43 | 43 | |-------------------------------------------------------------------------- |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | | This is used to verify the decoded tokens when using RS256 |
60 | 60 | | |
61 | 61 | */ |
62 | - 'authorized_issuers' => [env('AUTH0_DOMAIN')], |
|
62 | + 'authorized_issuers' => [ env('AUTH0_DOMAIN') ], |
|
63 | 63 | |
64 | 64 | /* |
65 | 65 | |-------------------------------------------------------------------------- |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | | Token decoding algorithms supported by your API |
86 | 86 | | |
87 | 87 | */ |
88 | - 'supported_algs' => ['RS256'], |
|
88 | + 'supported_algs' => [ 'RS256' ], |
|
89 | 89 | |
90 | 90 | /* |
91 | 91 | |-------------------------------------------------------------------------- |
@@ -38,14 +38,14 @@ |
||
38 | 38 | $user = $this->auth0Repository->getUserByDecodedJWT($tokenInfo); |
39 | 39 | |
40 | 40 | if (!$user) { |
41 | - return response()->json(['error' => 'Unauthorized user'], 401); |
|
41 | + return response()->json([ 'error' => 'Unauthorized user' ], 401); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | \Auth::login($user); |
45 | 45 | } catch (InvalidTokenException $e) { |
46 | - return response()->json(['error' => "Invalid or no token set"], 401); |
|
46 | + return response()->json([ 'error' => "Invalid or no token set" ], 401); |
|
47 | 47 | } catch (CoreException $e) { |
48 | - return response()->json(['error' => $e->getMessage()], 401); |
|
48 | + return response()->json([ 'error' => $e->getMessage() ], 401); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $next($request); |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | $apiDomain = strtolower(env('API_URL')); |
53 | 53 | $apiDomain = str_replace('http://', '', $apiDomain); |
54 | 54 | $apiDomain = str_replace('https://', '', $apiDomain); |
55 | - $moduleNamespace = $route[1]; |
|
56 | - $moduleName = explode('\\', $moduleNamespace)[1]; |
|
57 | - $controllerNamespace = $moduleNamespace . '\\' . 'Http\\Controllers'; |
|
58 | - $modelNameSpace = $moduleNamespace . '\\' . 'Entities\\' . $moduleName; |
|
59 | - $filepath = $route[0]; |
|
55 | + $moduleNamespace = $route[ 1 ]; |
|
56 | + $moduleName = explode('\\', $moduleNamespace)[ 1 ]; |
|
57 | + $controllerNamespace = $moduleNamespace.'\\'.'Http\\Controllers'; |
|
58 | + $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName; |
|
59 | + $filepath = $route[ 0 ]; |
|
60 | 60 | Route::group([ |
61 | 61 | 'prefix' => 'v1', |
62 | 62 | 'namespace' => $controllerNamespace, |
63 | 63 | 'domain' => $apiDomain, |
64 | - 'middleware' => ['api'], |
|
65 | - ], function (Router $router) use ($filepath) { |
|
64 | + 'middleware' => [ 'api' ], |
|
65 | + ], function(Router $router) use ($filepath) { |
|
66 | 66 | require $filepath; |
67 | 67 | }); |
68 | 68 | Route::model(strtolower($moduleName), $modelNameSpace); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | { |
79 | 79 | foreach ($this->bootstrapService->getConfigs() as $route) { |
80 | 80 | $this->publishes([ |
81 | - $route[0] => config_path($route[1]), |
|
81 | + $route[ 0 ] => config_path($route[ 1 ]), |
|
82 | 82 | ], 'config'); |
83 | 83 | $this->mergeConfigFrom( |
84 | - $route[0], basename($route[1], '.php') |
|
84 | + $route[ 0 ], basename($route[ 1 ], '.php') |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | { |
122 | 122 | $app = $this->app; |
123 | 123 | $service = $this->bootstrapService; |
124 | - $this->app->extend('command.seed', function () use ($app, $service) { |
|
125 | - return new SeedCommand($app['db'], $service); |
|
124 | + $this->app->extend('command.seed', function() use ($app, $service) { |
|
125 | + return new SeedCommand($app[ 'db' ], $service); |
|
126 | 126 | }); |
127 | 127 | } |
128 | 128 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function getUserByUserInfo($userInfo) |
44 | 44 | { |
45 | - return $this->upsertUser($userInfo['profile']); |
|
45 | + return $this->upsertUser($userInfo[ 'profile' ]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | protected function upsertUser($profile) |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | throw new Exception("Missing token information: Auth0 user id is not set"); |
52 | 52 | |
53 | 53 | $identifier = explode('|', $profile->user_id); |
54 | - $identityProvider = $identifier[0]; |
|
55 | - $id = $identifier[1]; |
|
54 | + $identityProvider = $identifier[ 0 ]; |
|
55 | + $id = $identifier[ 1 ]; |
|
56 | 56 | |
57 | 57 | $user = $this->service->find($id); |
58 | 58 |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | protected function upsertUser($profile) |
49 | 49 | { |
50 | - if (!isset($profile->user_id)) |
|
51 | - throw new Exception("Missing token information: Auth0 user id is not set"); |
|
50 | + if (!isset($profile->user_id)) { |
|
51 | + throw new Exception("Missing token information: Auth0 user id is not set"); |
|
52 | + } |
|
52 | 53 | |
53 | 54 | $identifier = explode('|', $profile->user_id); |
54 | 55 | $identityProvider = $identifier[0]; |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | if ($user === null || !$this->userEqualsProfile($user, $profile)) { |
60 | 61 | try { |
61 | 62 | |
62 | - if ($user === null) |
|
63 | - $user = new User(); |
|
63 | + if ($user === null) { |
|
64 | + $user = new User(); |
|
65 | + } |
|
64 | 66 | |
65 | 67 | $user->_id = new ObjectId($id); |
66 | 68 | $user->provider = $identityProvider; |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | private function getUserTokenData(): \stdClass |
29 | 29 | { |
30 | - return Cache::remember('testing:http_access_token', 60, function () { |
|
30 | + return Cache::remember('testing:http_access_token', 60, function() { |
|
31 | 31 | $httpClient = new Client(); |
32 | - $response = $httpClient->post(config('laravel-auth0.domain') . 'oauth/token', [ |
|
32 | + $response = $httpClient->post(config('laravel-auth0.domain').'oauth/token', [ |
|
33 | 33 | 'form_params' => [ |
34 | 34 | 'grant_type' => 'password', |
35 | 35 | 'client_id' => 'Dik7up1ZsRePpdZNjzrHIAUHe8mCb3RK', |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | private function sendRequest(string $method, string $route, array $payload = array(), $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
51 | 51 | { |
52 | 52 | return $this->json($method, $route, $payload, $authenticated ? [ |
53 | - "Authorization" => "Bearer " . $this->getUserTokenData()->id_token |
|
54 | - ] : []); |
|
53 | + "Authorization" => "Bearer ".$this->getUserTokenData()->id_token |
|
54 | + ] : [ ]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function httpNoAuth(string $method, string $route, array $payload = array()) |
@@ -14,6 +14,6 @@ |
||
14 | 14 | |
15 | 15 | protected $collection = 'users'; |
16 | 16 | |
17 | - protected $guarded = []; |
|
17 | + protected $guarded = [ ]; |
|
18 | 18 | |
19 | 19 | } |