| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | |
| 24 | 24 | $container = $app->getContainer(); | 
| 25 | 25 | |
| 26 | -$container['db'] = function ($container) use ($capsule) { | |
| 26 | +$container['db'] = function($container) use ($capsule) { | |
| 27 | 27 | return $capsule; | 
| 28 | 28 | }; | 
| 29 | 29 | |
| @@ -35,7 +35,7 @@ discard block | ||
| 35 | 35 | return new \Slim\Flash\Messages; | 
| 36 | 36 | }; | 
| 37 | 37 | |
| 38 | -$container['view'] = function ($container) { | |
| 38 | +$container['view'] = function($container) { | |
| 39 | 39 | $view = new \Slim\Views\Twig(__DIR__ . '/../resources/views/', [ | 
| 40 | 40 | 'cache' => false, | 
| 41 | 41 | ]); | 
| @@ -45,17 +45,17 @@ discard block | ||
| 45 | 45 | $container->request->getUri() | 
| 46 | 46 | )); | 
| 47 | 47 | |
| 48 | -	$view->getEnvironment()->addGlobal('auth',[ | |
| 48 | +	$view->getEnvironment()->addGlobal('auth', [ | |
| 49 | 49 | 'check' => $container->auth->check(), | 
| 50 | 50 | 'user' => $container->auth->user() | 
| 51 | 51 | ]); | 
| 52 | 52 | |
| 53 | -	$view->getEnvironment()->addGlobal('flash',$container->flash); | |
| 53 | +	$view->getEnvironment()->addGlobal('flash', $container->flash); | |
| 54 | 54 | |
| 55 | 55 | return $view; | 
| 56 | 56 | }; | 
| 57 | 57 | |
| 58 | -$container['validator'] = function ($container) { | |
| 58 | +$container['validator'] = function($container) { | |
| 59 | 59 | return new App\Validation\Validator; | 
| 60 | 60 | }; | 
| 61 | 61 | |
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | require __DIR__ . '/../vendor/autoload.php'; | 
| 8 | 8 | |
| 9 | 9 |  try { | 
| 10 | - $dotenv = (new \Dotenv\Dotenv(__DIR__ . '/../'))->load(); | |
| 10 | + $dotenv = (new \Dotenv\Dotenv(__DIR__ . '/../'))->load(); | |
| 11 | 11 |  } catch (\Dotenv\Exception\InvalidPathException $e) { | 
| 12 | - // | |
| 12 | + // | |
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 | $app = new \Slim\App([ | 
| @@ -3,15 +3,15 @@ | ||
| 3 | 3 | $capsule = new \Illuminate\Database\Capsule\Manager; | 
| 4 | 4 | |
| 5 | 5 | $capsule->addConnection([ | 
| 6 | -    'driver' => getenv('DB_DRIVER'), | |
| 7 | -    'host' => getenv('DB_HOST'), | |
| 8 | -    'database' => getenv('DB_DATABASE'), | |
| 9 | -    'username' => getenv('DB_USERNAME'), | |
| 10 | -    'password' => getenv('DB_PASSWORD'), | |
| 11 | - 'charset' => 'utf8', | |
| 12 | -    'port' => getenv('DB_PORT'), | |
| 13 | - 'collation' => 'utf8_unicode_ci', | |
| 14 | - 'prefix' => '' | |
| 6 | +	'driver' => getenv('DB_DRIVER'), | |
| 7 | +	'host' => getenv('DB_HOST'), | |
| 8 | +	'database' => getenv('DB_DATABASE'), | |
| 9 | +	'username' => getenv('DB_USERNAME'), | |
| 10 | +	'password' => getenv('DB_PASSWORD'), | |
| 11 | + 'charset' => 'utf8', | |
| 12 | +	'port' => getenv('DB_PORT'), | |
| 13 | + 'collation' => 'utf8_unicode_ci', | |
| 14 | + 'prefix' => '' | |
| 15 | 15 | ]); | 
| 16 | 16 | |
| 17 | 17 | $capsule->setAsGlobal(); | 
| @@ -2,7 +2,6 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace App\Controllers\Auth; | 
| 4 | 4 | |
| 5 | -use App\Models\User; | |
| 6 | 5 | use App\Controllers\Controller; | 
| 7 | 6 | use Respect\Validation\Validator as v; | 
| 8 | 7 | |
| @@ -9,14 +9,14 @@ discard block | ||
| 9 | 9 | |
| 10 | 10 | class PasswordController extends Controller | 
| 11 | 11 |  { | 
| 12 | - public function getChangePassword($request,$response) | |
| 12 | + public function getChangePassword($request, $response) | |
| 13 | 13 |  	{ | 
| 14 | - return $this->view->render($response,'auth/password/change.twig'); | |
| 14 | + return $this->view->render($response, 'auth/password/change.twig'); | |
| 15 | 15 | } | 
| 16 | 16 | |
| 17 | - public function postChangePassword($request,$response) | |
| 17 | + public function postChangePassword($request, $response) | |
| 18 | 18 |  	{ | 
| 19 | - $validation = $this->validator->validate($request,[ | |
| 19 | + $validation = $this->validator->validate($request, [ | |
| 20 | 20 | 'password_old' => v::noWhitespace()->notEmpty()->matchesPassword($this->auth->user()->password), | 
| 21 | 21 | 'password' => v::noWhitespace()->notEmpty(), | 
| 22 | 22 | ]); | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | |
| 28 | 28 |  		$this->auth->user()->setPassword($request->getParam('password')); | 
| 29 | 29 | |
| 30 | -		$this->flash->addMessage('info','Your password was changed'); | |
| 30 | +		$this->flash->addMessage('info', 'Your password was changed'); | |
| 31 | 31 | |
| 32 | 32 |  		return $response->withRedirect($this->router->pathFor('home')); | 
| 33 | 33 | |
| @@ -2,8 +2,6 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace App\Controllers; | 
| 4 | 4 | |
| 5 | -use App\Models\User; | |
| 6 | - | |
| 7 | 5 | class HomeController extends Controller | 
| 8 | 6 |  { | 
| 9 | 7 | public function index($request,$response) | 
| @@ -6,8 +6,8 @@ | ||
| 6 | 6 | |
| 7 | 7 | class HomeController extends Controller | 
| 8 | 8 |  { | 
| 9 | - public function index($request,$response) | |
| 9 | + public function index($request, $response) | |
| 10 | 10 |  	{ | 
| 11 | - return $this->view->render($response,'home.twig'); | |
| 11 | + return $this->view->render($response, 'home.twig'); | |
| 12 | 12 | } | 
| 13 | 13 | } | 
| 14 | 14 | \ No newline at end of file | 
| @@ -9,18 +9,18 @@ discard block | ||
| 9 | 9 | |
| 10 | 10 | class AuthController extends Controller | 
| 11 | 11 |  { | 
| 12 | - public function getSignOut($request,$response) | |
| 12 | + public function getSignOut($request, $response) | |
| 13 | 13 |  	{ | 
| 14 | 14 | $this->auth->logout(); | 
| 15 | 15 |  		return $response->withRedirect($this->router->pathFor('home')); | 
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | - public function getSignIn($request,$response) | |
| 18 | + public function getSignIn($request, $response) | |
| 19 | 19 |  	{ | 
| 20 | - return $this->view->render($response,'auth/signin.twig'); | |
| 20 | + return $this->view->render($response, 'auth/signin.twig'); | |
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | - public function postSignIn($request,$response) | |
| 23 | + public function postSignIn($request, $response) | |
| 24 | 24 |  	{ | 
| 25 | 25 | $auth = $this->auth->attempt( | 
| 26 | 26 |  			$request->getParam('email'), | 
| @@ -28,22 +28,22 @@ discard block | ||
| 28 | 28 | ); | 
| 29 | 29 | |
| 30 | 30 |  		if (!$auth) { | 
| 31 | -			$this->flash->addMessage('error','Could not sign you in with those details'); | |
| 31 | +			$this->flash->addMessage('error', 'Could not sign you in with those details'); | |
| 32 | 32 |  			return $response->withRedirect($this->router->pathFor('auth.signin')); | 
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 |  		return $response->withRedirect($this->router->pathFor('home')); | 
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | - public function getSignUp($request,$response) | |
| 38 | + public function getSignUp($request, $response) | |
| 39 | 39 |  	{ | 
| 40 | - return $this->view->render($response,'auth/signup.twig'); | |
| 40 | + return $this->view->render($response, 'auth/signup.twig'); | |
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | - public function postSignUp($request,$response) | |
| 43 | + public function postSignUp($request, $response) | |
| 44 | 44 |  	{ | 
| 45 | 45 | |
| 46 | - $validation = $this->validator->validate($request,[ | |
| 46 | + $validation = $this->validator->validate($request, [ | |
| 47 | 47 | 'email' => v::noWhitespace()->notEmpty()->email()->emailAvailable(), | 
| 48 | 48 | 'name' => v::noWhitespace()->notEmpty()->alpha(), | 
| 49 | 49 | 'password' => v::noWhitespace()->notEmpty(), | 
| @@ -56,12 +56,12 @@ discard block | ||
| 56 | 56 | $user = User::create([ | 
| 57 | 57 |  			'email' => $request->getParam('email'), | 
| 58 | 58 |  			'name' => $request->getParam('name'), | 
| 59 | -			'password' => password_hash($request->getParam('password'),PASSWORD_DEFAULT), | |
| 59 | +			'password' => password_hash($request->getParam('password'), PASSWORD_DEFAULT), | |
| 60 | 60 | ]); | 
| 61 | 61 | |
| 62 | -		$this->flash->addMessage('info','You have been signed up'); | |
| 62 | +		$this->flash->addMessage('info', 'You have been signed up'); | |
| 63 | 63 | |
| 64 | -		$this->auth->attempt($user->email,$request->getParam('password')); | |
| 64 | +		$this->auth->attempt($user->email, $request->getParam('password')); | |
| 65 | 65 | |
| 66 | 66 |  		return $response->withRedirect($this->router->pathFor('home')); | 
| 67 | 67 | } | 
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | public function setPassword($password) | 
| 22 | 22 |  	{ | 
| 23 | 23 | $this->update([ | 
| 24 | - 'password' => password_hash($password,PASSWORD_DEFAULT) | |
| 24 | + 'password' => password_hash($password, PASSWORD_DEFAULT) | |
| 25 | 25 | ]); | 
| 26 | 26 | } | 
| 27 | 27 | } | 
| 28 | 28 | \ No newline at end of file | 
| @@ -8,12 +8,12 @@ | ||
| 8 | 8 | class OldInputMiddleware extends Middleware | 
| 9 | 9 |  { | 
| 10 | 10 | |
| 11 | - public function __invoke($request,$response,$next) | |
| 11 | + public function __invoke($request, $response, $next) | |
| 12 | 12 |  	{ | 
| 13 | -		$this->container->view->getEnvironment()->addGlobal('old',isset($_SESSION['old']) ? $_SESSION['old'] : ''); | |
| 13 | +		$this->container->view->getEnvironment()->addGlobal('old', isset($_SESSION['old']) ? $_SESSION['old'] : ''); | |
| 14 | 14 | $_SESSION['old'] = $request->getParams(); | 
| 15 | 15 | |
| 16 | - $response = $next($request,$response); | |
| 16 | + $response = $next($request, $response); | |
| 17 | 17 | return $response; | 
| 18 | 18 | |
| 19 | 19 | } | 
| @@ -8,13 +8,13 @@ | ||
| 8 | 8 | class ValidationErrorsMiddleware extends Middleware | 
| 9 | 9 |  { | 
| 10 | 10 | |
| 11 | - public function __invoke($request,$response,$next) | |
| 11 | + public function __invoke($request, $response, $next) | |
| 12 | 12 |  	{ | 
| 13 | 13 | // var_dump(isset($_SESSION['errors']));die(); | 
| 14 | -		$this->container->view->getEnvironment()->addGlobal('errors',isset($_SESSION['errors']) ? $_SESSION['errors'] : ''); | |
| 14 | +		$this->container->view->getEnvironment()->addGlobal('errors', isset($_SESSION['errors']) ? $_SESSION['errors'] : ''); | |
| 15 | 15 | unset($_SESSION['errors']); | 
| 16 | 16 | |
| 17 | - $response = $next($request,$response); | |
| 17 | + $response = $next($request, $response); | |
| 18 | 18 | return $response; | 
| 19 | 19 | |
| 20 | 20 | } | 
| @@ -8,18 +8,18 @@ | ||
| 8 | 8 | class CsrfViewMiddleware extends Middleware | 
| 9 | 9 |  { | 
| 10 | 10 | |
| 11 | - public function __invoke($request,$response,$next) | |
| 11 | + public function __invoke($request, $response, $next) | |
| 12 | 12 |  	{ | 
| 13 | -		$this->container->view->getEnvironment()->addGlobal('csrf',[ | |
| 13 | +		$this->container->view->getEnvironment()->addGlobal('csrf', [ | |
| 14 | 14 | 'field' => ' | 
| 15 | - <input type="hidden" name="'. $this->container->csrf->getTokenNameKey() .'" | |
| 16 | - value="'. $this->container->csrf->getTokenName() .'"> | |
| 17 | - <input type="hidden" name="'. $this->container->csrf->getTokenValueKey() .'" | |
| 18 | - value="'. $this->container->csrf->getTokenValue() .'"> | |
| 15 | + <input type="hidden" name="'. $this->container->csrf->getTokenNameKey() . '" | |
| 16 | + value="'. $this->container->csrf->getTokenName() . '"> | |
| 17 | + <input type="hidden" name="'. $this->container->csrf->getTokenValueKey() . '" | |
| 18 | + value="'. $this->container->csrf->getTokenValue() . '"> | |
| 19 | 19 | ', | 
| 20 | 20 | ]); | 
| 21 | 21 | |
| 22 | - $response = $next($request,$response); | |
| 22 | + $response = $next($request, $response); | |
| 23 | 23 | return $response; | 
| 24 | 24 | |
| 25 | 25 | } |