@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | // monolog settings |
9 | 9 | 'logger' => [ |
10 | 10 | 'name' => 'app', |
11 | - 'path' => __DIR__ . '/../log/app.log', |
|
11 | + 'path' => __DIR__.'/../log/app.log', |
|
12 | 12 | 'level' => Monolog\Logger::DEBUG, |
13 | 13 | ], |
14 | 14 | |
15 | - 'mailTemplate' => __DIR__ . '/../mail', |
|
15 | + 'mailTemplate' => __DIR__.'/../mail', |
|
16 | 16 | |
17 | 17 | // DB |
18 | - 'database' => require(__DIR__ . '/../config/db.php'), |
|
18 | + 'database' => require(__DIR__.'/../config/db.php'), |
|
19 | 19 | |
20 | 20 | // ACL |
21 | 21 | 'acl' => [ |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * specified here so can be used in the code if needs be |
31 | 31 | * Example: ['user' => null] |
32 | 32 | */ |
33 | - 'resources' => [ ], |
|
33 | + 'resources' => [], |
|
34 | 34 | // where we specify the guarding! |
35 | 35 | 'guards' => [ |
36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * if included all resources default to deny unless specified. |
40 | 40 | * Example: ['user', ['admin']] |
41 | 41 | */ |
42 | - 'resources' => [ ], |
|
42 | + 'resources' => [], |
|
43 | 43 | /** |
44 | 44 | * list of literal routes for guarding. |
45 | 45 | * optional |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * ['route', ['roles'], ['methods',' methods1']] |
49 | 49 | */ |
50 | 50 | 'routes' => [ |
51 | - ['/api/token', ['guest'], ['post']], |
|
52 | - ['/api/user', ['user'], ['get']], |
|
51 | + ['/api/token', ['guest'], ['post']], |
|
52 | + ['/api/user', ['user'], ['get']], |
|
53 | 53 | ], |
54 | 54 | /** |
55 | 55 | * list of callables to resolve against |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * ['callable', ['roles']] |
60 | 60 | */ |
61 | 61 | 'callables' => [ |
62 | - ['App\Controller\CrudController', ['user']], |
|
63 | - ['App\Controller\CrudController:actionIndex', ['user']], |
|
64 | - ['App\Controller\CrudController:actionGet', ['user']], |
|
62 | + ['App\Controller\CrudController', ['user']], |
|
63 | + ['App\Controller\CrudController:actionIndex', ['user']], |
|
64 | + ['App\Controller\CrudController:actionGet', ['user']], |
|
65 | 65 | ['App\Controller\CrudController:actionCreate', ['user']], |
66 | 66 | ['App\Controller\CrudController:actionUpdate', ['user']], |
67 | 67 | ['App\Controller\CrudController:actionDelete', ['user']], |
68 | 68 | |
69 | - ['App\Controller\UserController:actionIndex', ['user']], |
|
70 | - ['App\Controller\UserController:actionGet', ['user']], |
|
69 | + ['App\Controller\UserController:actionIndex', ['user']], |
|
70 | + ['App\Controller\UserController:actionGet', ['user']], |
|
71 | 71 | ['App\Controller\UserController:actionCreate', ['admin']], |
72 | 72 | ['App\Controller\UserController:actionUpdate', ['admin']], |
73 | 73 | ['App\Controller\UserController:actionDelete', ['admin']], |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | ], |
92 | 92 | |
93 | 93 | 'translate' => [ |
94 | - 'path' => __DIR__ . '/../lang', |
|
94 | + 'path' => __DIR__.'/../lang', |
|
95 | 95 | 'locale' => 'ru', |
96 | 96 | ], |
97 | 97 | |
98 | - 'params' => require(__DIR__ . '/../config/params.php'), |
|
98 | + 'params' => require(__DIR__.'/../config/params.php'), |
|
99 | 99 | ], |
100 | 100 | ]; |
@@ -42,12 +42,12 @@ |
||
42 | 42 | * |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - public static function generateRandomString($length=32) |
|
45 | + public static function generateRandomString($length = 32) |
|
46 | 46 | { |
47 | 47 | $chars = 'abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ023456789'; |
48 | 48 | $charsCount = strlen($chars); |
49 | 49 | |
50 | - srand((double)microtime()*1000000); |
|
50 | + srand((double)microtime() * 1000000); |
|
51 | 51 | $i = 1; |
52 | 52 | $token = ''; |
53 | 53 |
@@ -51,8 +51,7 @@ |
||
51 | 51 | $i = 1; |
52 | 52 | $token = ''; |
53 | 53 | |
54 | - while ($i <= $length) |
|
55 | - { |
|
54 | + while ($i <= $length) { |
|
56 | 55 | $num = rand() % $charsCount; |
57 | 56 | $tmp = substr($chars, $num, 1); |
58 | 57 | $token .= $tmp; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public $timestamps = false; |
26 | 26 | |
27 | - public function user(){ |
|
27 | + public function user() { |
|
28 | 28 | return $this->belongsTo('App\Model\User'); |
29 | 29 | } |
30 | 30 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function createRefreshToken(User $user) |
54 | 54 | { |
55 | - $refreshToken = md5(Helper::generateRandomString() . '_' . time()); |
|
55 | + $refreshToken = md5(Helper::generateRandomString().'_'.time()); |
|
56 | 56 | |
57 | 57 | $user->refresh_tokens()->create([ |
58 | 58 | 'refresh_token' => $refreshToken, |
@@ -24,7 +24,8 @@ |
||
24 | 24 | |
25 | 25 | public $timestamps = false; |
26 | 26 | |
27 | - public function user(){ |
|
27 | + public function user() |
|
28 | + { |
|
28 | 29 | return $this->belongsTo('App\Model\User'); |
29 | 30 | } |
30 | 31 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public $timestamps = false; |
26 | 26 | |
27 | - public function user(){ |
|
27 | + public function user() { |
|
28 | 28 | return $this->belongsTo('App\Model\User'); |
29 | 29 | } |
30 | 30 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | try { |
57 | 57 | $payload = JWT::decode($token, getenv('SECRET_KEY'), ['HS256']); |
58 | 58 | return in_array($payload->aud, $whiteList); |
59 | - } catch (\Exception $e){ |
|
59 | + } catch (\Exception $e) { |
|
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | } |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | |
25 | 25 | public $timestamps = false; |
26 | 26 | |
27 | - public function user(){ |
|
27 | + public function user() |
|
28 | + { |
|
28 | 29 | return $this->belongsTo('App\Model\User'); |
29 | 30 | } |
30 | 31 | |
@@ -56,7 +57,7 @@ discard block |
||
56 | 57 | try { |
57 | 58 | $payload = JWT::decode($token, getenv('SECRET_KEY'), ['HS256']); |
58 | 59 | return in_array($payload->aud, $whiteList); |
59 | - } catch (\Exception $e){ |
|
60 | + } catch (\Exception $e) { |
|
60 | 61 | return false; |
61 | 62 | } |
62 | 63 | } |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | class CreateAccessTokensTable |
5 | 5 | { |
6 | 6 | /** |
7 | - * Do the migration |
|
8 | - */ |
|
7 | + * Do the migration |
|
8 | + */ |
|
9 | 9 | public function up() |
10 | 10 | { |
11 | 11 | Capsule::schema()->create('access_tokens', function($table) |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
22 | - * Undo the migration |
|
23 | - */ |
|
22 | + * Undo the migration |
|
23 | + */ |
|
24 | 24 | public function down() |
25 | 25 | { |
26 | 26 | Capsule::schema()->drop('access_tokens'); |
@@ -8,8 +8,7 @@ |
||
8 | 8 | */ |
9 | 9 | public function up() |
10 | 10 | { |
11 | - Capsule::schema()->create('access_tokens', function($table) |
|
12 | - { |
|
11 | + Capsule::schema()->create('access_tokens', function($table) { |
|
13 | 12 | $table->increments('id'); |
14 | 13 | $table->integer('user_id')->unsigned()->index(); |
15 | 14 | $table->string('access_token')->unique()->nullable(); |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | class CreateRefreshTokensTable |
5 | 5 | { |
6 | 6 | /** |
7 | - * Do the migration |
|
8 | - */ |
|
7 | + * Do the migration |
|
8 | + */ |
|
9 | 9 | public function up() |
10 | 10 | { |
11 | 11 | Capsule::schema()->create('refresh_tokens', function($table) |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
22 | - * Undo the migration |
|
23 | - */ |
|
22 | + * Undo the migration |
|
23 | + */ |
|
24 | 24 | public function down() |
25 | 25 | { |
26 | 26 | Capsule::schema()->drop('refresh_tokens'); |
@@ -8,8 +8,7 @@ |
||
8 | 8 | */ |
9 | 9 | public function up() |
10 | 10 | { |
11 | - Capsule::schema()->create('refresh_tokens', function($table) |
|
12 | - { |
|
11 | + Capsule::schema()->create('refresh_tokens', function($table) { |
|
13 | 12 | $table->increments('id'); |
14 | 13 | $table->integer('user_id')->unsigned()->index(); |
15 | 14 | $table->string('refresh_token')->unique()->nullable(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | - $timestamp = (int) substr($token, strrpos($token, '_') + 1); |
|
141 | + $timestamp = (int)substr($token, strrpos($token, '_') + 1); |
|
142 | 142 | $expire = 3600; |
143 | 143 | return $timestamp + $expire >= time(); |
144 | 144 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function generatePasswordResetToken() |
150 | 150 | { |
151 | - $this->password_reset_token = Helper::generateRandomString() . '_' . time(); |
|
151 | + $this->password_reset_token = Helper::generateRandomString().'_'.time(); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | $config = $container['settings']; |
17 | 17 | |
18 | - $container['mailer'] = function () use ($config) { |
|
18 | + $container['mailer'] = function() use ($config) { |
|
19 | 19 | $transport = \Swift_MailTransport::newInstance(); |
20 | 20 | $mailer = \Swift_Mailer::newInstance($transport); |
21 | 21 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function register(Container $container) |
16 | 16 | { |
17 | - $container['errorHandler'] = function (Container $container) { |
|
17 | + $container['errorHandler'] = function(Container $container) { |
|
18 | 18 | return function($request, $response, $exception) use ($container) { |
19 | 19 | $details = (defined('DEBUG_MODE') && DEBUG_MODE == 1) ? $exception->getMessage() : 'Internal server error'; |
20 | 20 | $error = new JsonException(null, 500, 'Internal server error', $details); |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | }; |
24 | 24 | }; |
25 | 25 | |
26 | - $container['notAllowedHandler'] = function () { |
|
26 | + $container['notAllowedHandler'] = function() { |
|
27 | 27 | return function($request, $response, $methods) { |
28 | 28 | throw new JsonException(null, 405, 'Method Not Allowed', 'Method must be one of: '.implode(', ', $methods)); |
29 | 29 | }; |
30 | 30 | }; |
31 | 31 | |
32 | - $container['notFoundHandler'] = function () { |
|
32 | + $container['notFoundHandler'] = function() { |
|
33 | 33 | return function() { |
34 | 34 | throw new JsonException(null, 404, 'Not found', 'Entity not found'); |
35 | 35 | }; |