@@ -3,9 +3,7 @@ |
||
3 | 3 | namespace App\Controllers\Auth; |
4 | 4 | |
5 | 5 | use App\Models\User; |
6 | -use App\Validation\Rules\EmailAvailable as EmailAvailable; |
|
7 | 6 | use App\Controllers\Controller; |
8 | -use App\Validation\Validator; |
|
9 | 7 | |
10 | 8 | class AuthController extends Controller |
11 | 9 | { |
@@ -2,10 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace App\Controllers\Auth; |
4 | 4 | |
5 | -use App\Models\User; |
|
6 | -use App\Validation\Rules\EmailAvailable as EmailAvailable; |
|
7 | 5 | use App\Controllers\Controller; |
8 | -use App\Validation\Validator; |
|
9 | 6 | |
10 | 7 | class PasswordController extends Controller |
11 | 8 | { |
@@ -8,8 +8,9 @@ |
||
8 | 8 | { |
9 | 9 | public function __invoke($request, $response, $next) |
10 | 10 | { |
11 | - if ($this->container->auth->check()) |
|
12 | - return $response->withRedirect($this->container->router->pathFor('home')); |
|
11 | + if ($this->container->auth->check()) { |
|
12 | + return $response->withRedirect($this->container->router->pathFor('home')); |
|
13 | + } |
|
13 | 14 | |
14 | 15 | $response = $next($request, $response); |
15 | 16 | return $response; |
@@ -19,11 +19,13 @@ |
||
19 | 19 | { |
20 | 20 | $user = User::find($_SESSION['user']); |
21 | 21 | |
22 | - if (!$user) |
|
23 | - return false; |
|
22 | + if (!$user) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | - if (!password_verify($value, $user->password)) |
|
26 | - return true; |
|
26 | + if (!password_verify($value, $user->password)) { |
|
27 | + return true; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | return false; |
29 | 31 | } |
@@ -19,11 +19,13 @@ |
||
19 | 19 | { |
20 | 20 | $user = User::find($_SESSION['user']); |
21 | 21 | |
22 | - if (!$user) |
|
23 | - return false; |
|
22 | + if (!$user) { |
|
23 | + return false; |
|
24 | + } |
|
24 | 25 | |
25 | - if (password_verify($value, $user->password)) |
|
26 | - return true; |
|
26 | + if (password_verify($value, $user->password)) { |
|
27 | + return true; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | return false; |
29 | 31 | } |
@@ -28,8 +28,9 @@ |
||
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
31 | - if (password_verify($value, $user->password)) |
|
32 | - return true; |
|
31 | + if (password_verify($value, $user->password)) { |
|
32 | + return true; |
|
33 | + } |
|
33 | 34 | |
34 | 35 | return false; |
35 | 36 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | 'name', |
23 | 23 | ]; |
24 | 24 | |
25 | - foreach($fields as $field) |
|
25 | + foreach ($fields as $field) |
|
26 | 26 | { |
27 | 27 | $this->addField($field, $request->getParam($field)); |
28 | 28 | $this->addRule($field, new Rule\Required())->setMessage('To pole nie może być puste'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'password', |
45 | 45 | ]; |
46 | 46 | |
47 | - foreach($fields as $field) |
|
47 | + foreach ($fields as $field) |
|
48 | 48 | { |
49 | 49 | $this->addField($field, $request->getParam($field)); |
50 | 50 | $this->addRule($field, new Rule\Required())->setMessage('To pole nie może być puste'); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'password2', |
65 | 65 | ]; |
66 | 66 | |
67 | - foreach($fields as $field) |
|
67 | + foreach ($fields as $field) |
|
68 | 68 | { |
69 | 69 | $this->addField($field, $request->getParam($field)); |
70 | 70 | $this->addRule($field, new Rule\Required())->setMessage('To pole nie może być puste'); |
@@ -20,8 +20,9 @@ |
||
20 | 20 | { |
21 | 21 | $user = User::where('email', $email)->first(); |
22 | 22 | |
23 | - if (!$user) |
|
24 | - return false; |
|
23 | + if (!$user) { |
|
24 | + return false; |
|
25 | + } |
|
25 | 26 | |
26 | 27 | if (password_verify($password, $user->password)) |
27 | 28 | { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | $container = $app->getContainer(); |
8 | 8 | |
9 | 9 | // Twig renderer |
10 | -$container['view'] = function ($c) |
|
10 | +$container['view'] = function($c) |
|
11 | 11 | { |
12 | 12 | $settings = $c->get('settings')['twig']; |
13 | 13 | |
@@ -39,52 +39,52 @@ discard block |
||
39 | 39 | $capsule->setAsGlobal(); |
40 | 40 | $capsule->bootEloquent(); |
41 | 41 | |
42 | -$container['db'] = function ($c) |
|
42 | +$container['db'] = function($c) |
|
43 | 43 | { |
44 | 44 | return $capsule; |
45 | 45 | }; |
46 | 46 | |
47 | 47 | // Controllers |
48 | 48 | |
49 | -$container['IndexController'] = function ($c) |
|
49 | +$container['IndexController'] = function($c) |
|
50 | 50 | { |
51 | 51 | return new \App\Controllers\IndexController($c); |
52 | 52 | }; |
53 | 53 | |
54 | -$container['ErrorController'] = function ($c) |
|
54 | +$container['ErrorController'] = function($c) |
|
55 | 55 | { |
56 | 56 | return new \App\Controllers\ErrorController($c); |
57 | 57 | }; |
58 | 58 | |
59 | -$container['AuthController'] = function ($c) |
|
59 | +$container['AuthController'] = function($c) |
|
60 | 60 | { |
61 | 61 | return new \App\Controllers\Auth\AuthController($c); |
62 | 62 | }; |
63 | 63 | |
64 | -$container['PasswordController'] = function ($c) |
|
64 | +$container['PasswordController'] = function($c) |
|
65 | 65 | { |
66 | 66 | return new \App\Controllers\Auth\PasswordController($c); |
67 | 67 | }; |
68 | 68 | |
69 | 69 | // Addons |
70 | 70 | |
71 | -$container['validator'] = function ($c) |
|
71 | +$container['validator'] = function($c) |
|
72 | 72 | { |
73 | 73 | return new \App\Validation\Validator; |
74 | 74 | }; |
75 | 75 | |
76 | -$container['csrf'] = function ($c) |
|
76 | +$container['csrf'] = function($c) |
|
77 | 77 | { |
78 | 78 | $guard = new \Slim\Csrf\Guard; |
79 | 79 | return $guard->setFailureCallable(new \App\Middleware\FormsMiddleware\CsrfErrorMiddleware($c)); |
80 | 80 | }; |
81 | 81 | |
82 | -$container['flash'] = function ($c) |
|
82 | +$container['flash'] = function($c) |
|
83 | 83 | { |
84 | 84 | return new \Slim\Flash\Messages; |
85 | 85 | }; |
86 | 86 | |
87 | -$container['auth'] = function ($c) |
|
87 | +$container['auth'] = function($c) |
|
88 | 88 | { |
89 | 89 | return new \App\Auth\Auth; |
90 | 90 | }; |
91 | 91 | \ No newline at end of file |