diff --git a/app/Kernel.php b/app/Kernel.php
index 9ad4035..42bcb9d 100644
--- a/app/Kernel.php
+++ b/app/Kernel.php
@@ -30,7 +30,11 @@ use Monolog\{
Handler\StreamHandler,
Logger
};
+use Sikofitt\App\Controller\DefaultController;
+use Sikofitt\App\Entity\User;
+use Sikofitt\App\Traits\EntityManagerTrait;
use Sikofitt\App\Traits\FlashTrait;
+use Sikofitt\Security\MySqlUserProvider;
use Silex\Application;
use Silex\Application\{
FormTrait,
@@ -72,6 +76,7 @@ use Symfony\Component\Translation\Translator;
*/
class Kernel extends Application
{
+ use EntityManagerTrait;
use FlashTrait;
use FormTrait;
use MonologTrait;
@@ -81,6 +86,7 @@ class Kernel extends Application
use TwigTrait;
use UrlGeneratorTrait;
+
/**
* Kernel constructor.
*
@@ -95,13 +101,19 @@ class Kernel extends Application
if (true === $debug) {
$this->setDebug();
}
+
$this->setUpProviders();
$this->setUpDatabase();
$this->setUpView();
$this->setUpLogger();
$this->setUpMailer();
}
+ public function setUpRoutes(\Kernel $app)
+ {
+ $app->match('/login', DefaultController::class.'::loginAction')
+ ->method('GET|POST');
+ }
/**
* @param array $values
*
@@ -266,8 +278,6 @@ class Kernel extends Application
* Closure supports \Twig_Environment and Silex\Application as a second
* parameter, but we never use Silex\Application so we leave it out.
*/
- $r = new \Symfony\Component\HttpFoundation\RequestStack();
-
$this->extend('twig', function (\Twig_Environment $twig) {
$twig->addGlobal('session', $this['session']);
$twig->addExtension(new TranslationExtension(new Translator('en')));
@@ -281,19 +291,57 @@ class Kernel extends Application
*/
protected function setUpProviders()
{
+ /*$this['app.mysql_authenticator'] = function($app) {
+ return new Sikofitt\Security\MysqlAuthenticator($app['security.encoder_factory'], $app->getEntityManager());
+ };
+ $this['security.firewalls'] = array(
+
+ 'login' => [
+ 'pattern' => '^/login$',
+ 'anonymous' => true,
+
+
+ ],
+ 'secured' => [
+ 'pattern' => '^/rsvp$',
+ 'guard' => [
+ 'authenticators' => [
+ 'app.mysql_authenticator',
+ ],
+ 'form' => [
+ 'login_path' => '/login',
+ 'check_path' => '/login',
+ ]
+
+ ],
+
+ 'users' => $this['users'] = function() {
+ return new MySqlUserProvider($this['orm.em']);
+ },
+ ],
+
+
+ // configure where your users come from. Hardcode them, or load them from somewhere
+ // http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-user-provider
+
+ // 'anonymous' => true
+
+ );*/
+ $this['protected_pages'] = function() {
+ return [
+ 'gallery',
+ 'rsvp/update'
+ ];
+ };
+
$this
->register(new CsrfServiceProvider())
->register(new FormServiceProvider())
- ->register(new SecurityServiceProvider(), [
- 'security.firewalls' => [
- 'admin' => [
- 'pattern' => '^/admin',
- 'http' => true,
- ],
- ],
- ])
+ //->register(new SecurityServiceProvider())
;
+
+
$this->extend('form.extensions', function ($extensions) {
return $extensions;
});
diff --git a/app/views/base.html.twig b/app/views/base.html.twig
index 3656cc3..fa3ed10 100644
--- a/app/views/base.html.twig
+++ b/app/views/base.html.twig
@@ -1,4 +1,6 @@
-
+{% if form is defined %}
+{% form_theme form with [_self, 'form_errors.html.twig'] %}
+{% endif %}
diff --git a/app/views/form_errors.html.twig b/app/views/form_errors.html.twig
new file mode 100644
index 0000000..d6c198d
--- /dev/null
+++ b/app/views/form_errors.html.twig
@@ -0,0 +1,22 @@
+
+{# form_errors.html.twig #}
+{% block form_errors %}
+ {% spaceless %}
+ {% if errors|length > 0 %}
+ {% if compound %}
+
+
+ {% for error in errors %}
+
{{ error.message }}
+ {% endfor %}
+
+ {% else %}
+
+
+ {% set error = errors|first %}
+
{{ error.message }}
+
+ {% endif %}
+ {% endif %}
+ {% endspaceless %}
+{% endblock form_errors %}
\ No newline at end of file
diff --git a/app/views/login.html.twig b/app/views/login.html.twig
new file mode 100644
index 0000000..8ef82ca
--- /dev/null
+++ b/app/views/login.html.twig
@@ -0,0 +1,38 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
+ {{ form_start(form) }}
+
+ {{ form_end(form) }}
+{% endblock %}
\ No newline at end of file
diff --git a/app/views/reset_password_token.html.twig b/app/views/reset_password_token.html.twig
new file mode 100644
index 0000000..16da54f
--- /dev/null
+++ b/app/views/reset_password_token.html.twig
@@ -0,0 +1,39 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
+ {% if token.valid == false %}
+
+ Sorry your token ({{ token.value }}) is invalid.
+
+
+ Please see {{ url('rsvp_password_reset') }}.
+
+{% else %}
+ {{ form_start(form) }}
+
+ {{ form_label(form.password.children.first) }}
+
+
+ {{ form_errors(form.password.children.first) }}
+ {{ form_widget(form.password.children.first) }}
+
+
+ {{ form_label(form.password.children.second) }}
+
+ {{ form_errors(form.password.children.second) }}
+ {{ form_widget(form.password.children.second) }}
+
+
+ {{ form_row(form.submit) }}
+
+
+
+ {{ form_rest(form) }}
+
+
+ {{ form_end(form) }}
+ {% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/app/views/rsvp_form.html.twig b/app/views/rsvp_form.html.twig
index 6a86881..229e8bf 100644
--- a/app/views/rsvp_form.html.twig
+++ b/app/views/rsvp_form.html.twig
@@ -2,6 +2,7 @@
{% block body %}
+ {{ dump(app.session.get('user')) }}
{{ form_start(form) }}