Docker updates

This commit is contained in:
R. Eric Wheeler 2017-04-09 18:08:01 -07:00
parent 4087c70ec8
commit bd716544b0
54 changed files with 891 additions and 139 deletions

View File

@ -18,6 +18,8 @@ class AppKernel extends Kernel
new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(), new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new \Snc\RedisBundle\SncRedisBundle(), new \Snc\RedisBundle\SncRedisBundle(),
new \HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
new \FOS\UserBundle\FOSUserBundle(),
new Sikofitt\DoughnutWeddingBundle\SikofittDoughnutWeddingBundle(), new Sikofitt\DoughnutWeddingBundle\SikofittDoughnutWeddingBundle(),
]; ];

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/ChangePassword/change_password_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_change_password'), 'attr': { 'class': 'fos_user_change_password' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'change_password.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/edit_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_group_edit', {'groupName': group_name}), 'attr': { 'class': 'fos_user_group_edit' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'group.edit.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/list_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,7 @@
<div class="fos_user_group_list">
<ul>
{% for group in groups %}
<li><a href="{{ path('fos_user_group_show', {'groupName': group.getName()} ) }}">{{ group.getName() }}</a></li>
{% endfor %}
</ul>
</div>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/new_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_group_new'), 'attr': { 'class': 'fos_user_group_new' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'group.new.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Group/show_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,5 @@
{% trans_default_domain 'FOSUserBundle' %}
<div class="fos_user_group_show">
<p>{{ 'group.show.name'|trans }}: {{ group.getName() }}</p>
</div>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Profile/edit_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_profile_edit'), 'attr': { 'class': 'fos_user_profile_edit' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'profile.edit.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Profile/show_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,6 @@
{% trans_default_domain 'FOSUserBundle' %}
<div class="fos_user_user_show">
<p>{{ 'profile.show.username'|trans }}: {{ user.username }}</p>
<p>{{ 'profile.show.email'|trans }}: {{ user.email }}</p>
</div>

View File

@ -0,0 +1,7 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>{{ 'registration.check_email'|trans({'%email%': user.email}) }}</p>
{% endblock fos_user_content %}

View File

@ -0,0 +1,10 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>{{ 'registration.confirmed'|trans({'%username%': user.username}) }}</p>
{% if targetUrl %}
<p><a href="{{ targetUrl }}">{{ 'registration.back'|trans }}</a></p>
{% endif %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,13 @@
{% trans_default_domain 'FOSUserBundle' %}
{% block subject %}
{%- autoescape false -%}
{{ 'registration.email.subject'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{%- endautoescape -%}
{% endblock %}
{% block body_text %}
{% autoescape false %}
{{ 'registration.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_html %}{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Registration/register_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,9 @@
{% extends "@FOSUser/layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block fos_user_content %}
<p>
{{ 'resetting.check_email'|trans({'%tokenLifetime%': tokenLifetime})|nl2br }}
</p>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% trans_default_domain 'FOSUserBundle' %}
{% block subject %}
{%- autoescape false -%}
{{ 'resetting.email.subject'|trans({'%username%': user.username}) }}
{%- endautoescape -%}
{% endblock %}
{% block body_text %}
{% autoescape false %}
{{ 'resetting.email.message'|trans({'%username%': user.username, '%confirmationUrl%': confirmationUrl}) }}
{% endautoescape %}
{% endblock %}
{% block body_html %}{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Resetting/request_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,11 @@
{% trans_default_domain 'FOSUserBundle' %}
<form action="{{ path('fos_user_resetting_send_email') }}" method="POST" class="fos_user_resetting_request">
<div>
<label for="username">{{ 'resetting.request.username'|trans }}</label>
<input type="text" id="username" name="username" required="required" />
</div>
<div>
<input type="submit" value="{{ 'resetting.request.submit'|trans }}" />
</div>
</form>

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "@FOSUser/Resetting/reset_content.html.twig" %}
{% endblock fos_user_content %}

View File

@ -0,0 +1,8 @@
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, { 'action': path('fos_user_resetting_reset', {'token': token}), 'attr': { 'class': 'fos_user_resetting_reset' } }) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'resetting.reset.submit'|trans }}" />
</div>
{{ form_end(form) }}

View File

@ -0,0 +1,5 @@
{% extends "@FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{{ include('@FOSUser/Security/login_content.html.twig') }}
{% endblock fos_user_content %}

View File

@ -0,0 +1,22 @@
{% trans_default_domain 'FOSUserBundle' %}
{% if error %}
<div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
<form action="{{ path("fos_user_security_check") }}" method="post">
{% if csrf_token %}
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
{% endif %}
<label for="username">{{ 'security.login.username'|trans }}</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" required="required" />
<label for="password">{{ 'security.login.password'|trans }}</label>
<input type="password" id="password" name="_password" required="required" />
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans }}</label>
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}" />
</form>

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
<a href="{{ path('fos_user_security_logout') }}">
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
</a>
{% else %}
<a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
{% endif %}
</div>
{% if app.request.hasPreviousSession %}
{% for type, messages in app.session.flashbag.all() %}
{% for message in messages %}
<div class="flash-{{ type }}">
{{ message }}
</div>
{% endfor %}
{% endfor %}
{% endif %}
<div>
{% block fos_user_content %}
{% endblock fos_user_content %}
</div>
</body>
</html>

View File

@ -0,0 +1,24 @@
{% extends 'HWIOAuthBundle::layout.html.twig' %}
{% block hwi_oauth_content %}
<h3>{{ 'header.connecting' | trans({}, 'HWIOAuthBundle')}}</h3>
<div class="row">
<div class="span6">
<p>{{ 'connect.confirm.text' | trans({'%service%': service | trans({}, 'HWIOAuthBundle'), '%name%': userInformation.realName}, 'HWIOAuthBundle') }}</p>
<p>
{{ form_start(form, {'action': path('hwi_oauth_connect_service', {'service': service, 'key': key}), 'attr': {'class': 'fos_user_registration_register'}}) }}
{{ form_widget(form) }}
<div>
<button type="submit" class="btn btn-primary">{{ 'connect.confirm.submit' | trans({}, 'HWIOAuthBundle') }}</button>
<a href="{{ path('hwi_oauth_connect') }}" class="btn">{{ 'connect.confirm.cancel' | trans({}, 'HWIOAuthBundle') }}</a>
</div>
{{ form_end(form) }}
</p>
</div>
<div class="span6">
{% if userInformation.profilePicture is defined and userInformation.profilePicture is not empty %}
<img src="{{ userInformation.profilePicture }}" />
{% endif %}
</div>
</div>
{% endblock hwi_oauth_content %}

View File

@ -0,0 +1,5 @@
{% extends 'HWIOAuthBundle::layout.html.twig' %}
{% block hwi_oauth_content %}
<h3>{{ 'header.success' | trans({'%name%': userInformation.realName}, 'HWIOAuthBundle') }}</h3>
{% endblock hwi_oauth_content %}

View File

@ -0,0 +1,10 @@
{% extends 'HWIOAuthBundle::layout.html.twig' %}
{% block hwi_oauth_content %}
{% if error is defined and error %}
<span>{{ error }}</span>
{% endif %}
{% for owner in hwi_oauth_resource_owners() %}
<a href="{{ hwi_oauth_login_url(owner) }}">{{ owner | trans({}, 'HWIOAuthBundle') }}</a> <br />
{% endfor %}
{% endblock hwi_oauth_content %}

View File

@ -0,0 +1,22 @@
{% extends 'HWIOAuthBundle::layout.html.twig' %}
{% block hwi_oauth_content %}
<h3>{{ 'header.register' | trans({'%name%': userInformation.realName}, 'HWIOAuthBundle') }}</h3>
<div class="row">
<div class="span6">
{{ form_start(form, {'action': path('hwi_oauth_connect_registration', {'key': key}), 'attr': {'class': 'hwi_oauth_registration_register'}}) }}
{{ form_widget(form) }}
<div>
<button type="submit" class="btn btn-primary">{{ 'connect.registration.submit'|trans({}, 'HWIOAuthBundle') }}</button>
<a href="{{ path('hwi_oauth_connect') }}" class="btn">{{ 'connect.registration.cancel' | trans({}, 'HWIOAuthBundle') }}</a>
</div>
{{ form_end(form) }}
</div>
<div class="span6">
{% if userInformation.profilePicture is not empty %}
<img src="{{ userInformation.profilePicture }}" />
{% endif %}
</div>
</div>
{% endblock hwi_oauth_content %}

View File

@ -0,0 +1,5 @@
{% extends 'HWIOAuthBundle::layout.html.twig' %}
{% block hwi_oauth_content %}
<h3>{{ 'header.registration_success' | trans({'%username%': app.user.username}, 'HWIOAuthBundle') }}</h3>
{% endblock hwi_oauth_content %}

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
{% block hwi_oauth_content %}
{% endblock hwi_oauth_content %}
</div>
</body>
</html>

View File

@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% block body %}
{% endblock %}
{% block stylesheets %}
{% endblock %}

View File

@ -2,9 +2,6 @@
{% block body %} {% block body %}
<h2 class="uk-text-center">You have been successfully logged out.</h2> <h2 class="uk-text-center">You have been successfully logged out.</h2>
<p class="uk-text-center"> <p class="uk-text-center">
You can log in again by going to the <a href="{{ url('login') }}">login</a> page. You can log in again by going to the <a href="/login">login</a> page.
</p>
<p class="uk-text-center">
You can also login using a token by going to the <a href="{{ url('token_login') }}">token login</a> page.
</p> </p>
{% endblock %} {% endblock %}

View File

@ -121,3 +121,67 @@ swiftmailer:
username: '%mailer_user%' username: '%mailer_user%'
password: '%mailer_password%' password: '%mailer_password%'
spool: { type: memory } spool: { type: memory }
hwi_oauth:
firewall_names: [secured_area]
resource_owners:
facebook:
type: facebook
client_id: '1821112348143190'
client_secret: '155bc602a7e30e4227625c29c8b124c6'
scope: 'email,public_profile'
google:
type: google
client_id: '1076229066413-3rf8q0qjurn4h190dagi98tp0a10obe6.apps.googleusercontent.com'
client_secret: 'zQN32g_7lUz4dZ7E9kgY6nHe'
scope: "email profile"
options:
access_type: offline
amazon:
type: amazon
client_id: 'amzn1.application-oa2-client.15f87b8a4f23465b9022ba0a3f55610d'
client_secret: '84d6f402c53386ae0f196062945f217dcc56e7b7122cffb76c95b6a5775d22e0'
instagram:
type: instagram
client_id: ' 70e7edd280834c429d49f985ff308230'
client_secret: '9c405020a3ef412086032a4514909705'
twitter:
type: twitter
client_id: 'YmXGQN2Az0eTlkwJrnaO2wR9r'
client_secret: 'c73cBI7uj562BU4bBSHfNDcKHgM5aVo8sousjgUdDNBZFXxFHI'
windows:
type: windows_live
client_id: 'f9dc3dd7-1b1c-4b8c-acdf-f40611ab550d'
client_secret: 'fy5prOcKeLKNTB616WinrPt'
scope: wl.signin
yahoo:
type: yahoo
client_id: 'dj0yJmk9SndXWm05Tk5yME9MJmQ9WVdrOVRYTkVUVWRHTjJjbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1lMw--'
client_secret: '4f837f738d6c4df38eaedc7babe4d8f405f8cc0f'
fosub:
# try 30 times to check if a username is available (foo, foo1, foo2 etc)
username_iterations: 30
# mapping between resource owners (see below) and properties
properties:
google: googleId
facebook: facebookId
amazon: amazonId
instagram: instagramId
twitter: twitterId
windows_live: windowsId
yahoo: yahooId
# if you want to use 'connect' and do not use the FOSUB integration, configure these separately
connect: ~
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: secured_area
user_class: Sikofitt\DoughnutWeddingBundle\Entity\User
from_email:
address: noreply@doughnutwedding.com
sender_name: "No Reply"
registration:
form:
type: Sikofitt\DoughnutWeddingBundle\Form\RegistrationType

View File

@ -1,3 +1,34 @@
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /user/connect
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /user/connect
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /user/oauth
facebook_login:
path: /user/login/callback/facebook
google_login:
path: /user/login/callback/google
twitter_login:
path: /user/login/callback/twitter
windows_login:
path: /user/login/callback/windows
instagram_login:
path: /user/login/callback/instagram
amazon_login:
path: /user/login/callback/amazon
yahoo_login:
path: /user/login/callback/yahoo
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
prefix: /user
sikofitt_doughnut_wedding: sikofitt_doughnut_wedding:
resource: "@SikofittDoughnutWeddingBundle/Controller/" resource: "@SikofittDoughnutWeddingBundle/Controller/"
type: annotation type: annotation

View File

@ -1,17 +1,48 @@
# To get started with security, check out the documentation: # To get started with security, check out the documentation:
# http://symfony.com/doc/current/security.html # http://symfony.com/doc/current/security.html
security: security:
encoders:
FOS\UserBundle\Model\UserInterface:
algorithm: bcrypt
cost: 14
# http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded # http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers: providers:
in_memory: #in_memory:
memory: ~ # memory: ~
fos_userbundle:
id: fos_user.user_provider.username
#id: fos_user.user_manager
firewalls: firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs # disables authentication for assets and the profiler, adapt it according to your needs
dev: dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/ pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false security: false
secured_area:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: /user/connect/
check_path: /login/login_check
logout:
path: /user/logout
target: /
anonymous: true
oauth:
resource_owners:
facebook: /user/login/callback/facebook
google: /user/login/callback/google
twitter: /user/login/callback/twitter
windows: /user/login/callback/windows
instagram: /user/login/callback/instagram
amazon: /user/login/callback/amazon
yahoo: /user/login/callback/yahoo
login_path: /user/oauth
use_forward: false
failure_path: /user/oauth
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
#oauth_user_provider:
# service: my.oauth_aware.user_provider.service
main: main:
anonymous: ~ anonymous: ~
@ -22,3 +53,8 @@ security:
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
#form_login: ~ #form_login: ~
access_control:
- { path: ^/user/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/user/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }

View File

@ -7,3 +7,8 @@ services:
class: Bramus\Monolog\Formatter\ColoredLineFormatter class: Bramus\Monolog\Formatter\ColoredLineFormatter
tags: tags:
- { name: 'monolog.logger' } - { name: 'monolog.logger' }
doughnutwedding.form.registration:
class: Sikofitt\DoughnutWeddingBundle\Form\RegistrationType
tags:
- { name: form.type, alias: app_user_registration }

View File

@ -18,7 +18,9 @@
"doctrine/doctrine-cache-bundle": "^1.3", "doctrine/doctrine-cache-bundle": "^1.3",
"doctrine/orm": "^2.5", "doctrine/orm": "^2.5",
"egulias/email-validator": "^2.1", "egulias/email-validator": "^2.1",
"friendsofsymfony/user-bundle": "^2.0",
"google/recaptcha": "^1.1", "google/recaptcha": "^1.1",
"hwi/oauth-bundle": "^0.5.3",
"incenteev/composer-parameter-handler": "^2.0", "incenteev/composer-parameter-handler": "^2.0",
"ircmaxell/random-lib": "^1.2", "ircmaxell/random-lib": "^1.2",
"ircmaxell/security-lib": "^1.1", "ircmaxell/security-lib": "^1.1",

View File

@ -7,16 +7,17 @@ server {
root /var/www/html; root /var/www/html;
location / { location / {
index index.php index.html;
try_files $uri /app_dev.php$is_args$args; try_files $uri /app_dev.php$is_args$args;
} }
#location ~ \.php$ {
location ~ \.php$ { location ~ ^/(app_dev|config)\.php(/|$) {
include fastcgi_params;
fastcgi_pass php:9000; fastcgi_pass php:9000;
fastcgi_index app_dev.php; fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
#fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
} }
} }

View File

@ -7,7 +7,7 @@ services:
- "80:80" - "80:80"
volumes: volumes:
- ./:/var/www - ./:/var/www
- ./html:/var/www/html - ./web:/var/www/html
- ./conf.d:/etc/nginx/conf.d - ./conf.d:/etc/nginx/conf.d
links: links:
- php - php

View File

@ -1,31 +1,34 @@
<?php <?php
/*
* doughnutwedding.com
* Copyright (C) 2017 http://doughnutwedding.com eric@doughnutwedding.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Sikofitt\DoughnutWeddingBundle\Controller; namespace Sikofitt\DoughnutWeddingBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
class DefaultController /**
* Class DefaultController
*/
class DefaultController extends Controller
{ {
public function indexAction(Request $request, \Kernel $app) /**
* @Route("/")
*
* @param Request $request
* @return Response
*/
public function indexAction(Request $request)
{ {
return $app->render('index.html.twig', ['request' => $request]); if(null === $user = $request->getUser()) {
return $this->render('default/index.html.twig', array(
'base_dir' => $this->get('kernel')->getRootDir(),
));
} }
return $this->render('default/index_user.html.twig', array(
'base_dir' => $this->get('kernel')->getRootDir(),
));
}
} }

View File

@ -21,30 +21,30 @@
namespace Sikofitt\DoughnutWeddingBundle\Controller; namespace Sikofitt\DoughnutWeddingBundle\Controller;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Sikofitt\{
App\Entity\Rsvp, App\Entity\User, App\Form\ResetPasswordType, App\Form\ResetType, App\Form\RsvpType, App\Repository\RsvpRepository, App\Repository\UserRepository
};
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\ConstraintViolationList;
class RsvpController class RsvpController extends Controller
{ {
/** /**
* @Route("/rsvp")
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
* @param \Kernel $app
* *
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/ */
public function indexAction(Request $request, \Kernel $app) public function indexAction(Request $request)
{ {
/** /**
* @var EntityManager $em * @var EntityManager $em
* @var RsvpRepository $rsvpRepo * @var RsvpRepository $rsvpRepo
* @var UserRepository $userRepo * @var UserRepository $userRepo
*/ */
$em = $app['orm.em']; $em = $this->get('doctrine.orm.entity_manager');
$rsvpRepo = $em->getRepository('Sikofitt:Rsvp'); $rsvpRepo = $em->getRepository('Sikofitt:Rsvp');
$count = (40 - $rsvpRepo->getRsvpCount()); $count = (40 - $rsvpRepo->getRsvpCount());
$userRepo = $em->getRepository('Sikofitt:User'); $userRepo = $em->getRepository('Sikofitt:User');

View File

@ -20,11 +20,11 @@
namespace Sikofitt\DoughnutWeddingBundle\Controller; namespace Sikofitt\DoughnutWeddingBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sikofitt\App\Form\UserLoginType; use Sikofitt\App\Form\UserLoginType;
use Sikofitt\App\Form\UserTokenType; use Sikofitt\App\Form\UserTokenType;
use Sikofitt\Security\TokenGenerator; use Sikofitt\DoughnutWeddingBundle\Security\TokenGenerator;
use Silex\Api\ControllerProviderInterface; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Silex\Application;
use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -33,127 +33,107 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
/** /**
* Class UserController. * Class UserController.
*/ */
class UserController implements ControllerProviderInterface class UserController extends Controller
{ {
public function connect(Application $app)
{
/** /**
* @var ControllerCollection $userControllers * @Route("/logout", name="logout")
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/ */
$userControllers = $app['controllers_factory']; public function logoutAction(Request $request)
$userControllers->match('/', __CLASS__.'::indexAction')
->method('GET')
->bind('user_index');
$userControllers->match('/login', __CLASS__.'::loginAction')
->method('GET|POST')
->bind('login');
$userControllers->get('/logout', __CLASS__.'::logoutAction')
->bind('logout');
$userControllers->match('/login/token/{token}', __CLASS__.'::tokenLoginAction')
->method('GET|POST')
->bind('token_login')
->value('token', null);
$userControllers->match('/reset', __CLASS__.'::resetAction')
->method('GET|POST')
->bind('user_reset');
$userControllers->match('/reset/{token}', __CLASS__.'::tokenAction')
->bind('user_reset_token')
->method('GET|POST');
//->before(new MysqlAuthenticatorMiddleware());
$userControllers->match('/edit', __CLASS__.'::editAction')
->method('GET|POST')
->bind('user_edit');
return $userControllers;
}
public function logoutAction(\Kernel $app)
{ {
if (true === $app->session()->has('user')) { if(null !== $request->getUser()) {
$app->session()->remove('user'); $request->getSession()->remove('user');
}
return $this->render('user/logout.html.twig');
} }
return $app->render('user/logout.html.twig'); public function tokenLoginAction(Request $request, string $token = null)
}
public function tokenLoginAction(Request $request, \Kernel $app, string $token = null)
{ {
if (null === $token) { if (null === $token) {
$tokenForm = $app->getFormFactory()->create(UserTokenType::class); $tokenForm = $this->get('form.factory')->create(UserTokenType::class);
if ($request->isMethod('POST')) { if ($request->isMethod('POST')) {
$tokenForm->handleRequest($request); $tokenForm->handleRequest($request);
if ($tokenForm->isValid() && $tokenForm->isSubmitted()) { if ($tokenForm->isValid() && $tokenForm->isSubmitted()) {
if ($tokenForm->get('update_token')->isClicked()) { if ($tokenForm->get('update_token')->isClicked()) {
if (null !== $tokenForm->get('email')->getData()) { if (null !== $tokenForm->get('email')->getData()) {
return $this->updateAndSendTokenLoginLink($app, return $this->updateAndSendTokenLoginLink($this,
$tokenForm); $tokenForm);
} else { } else {
$tokenForm->get('email') $tokenForm->get('email')
->addError(new FormError('Email address is a required field to send a new login link.')); ->addError(new FormError('Email address is a required field to send a new login link.'));
return $app->render('form/token.html.twig', return $this->render('form/token.html.twig',
['form' => $tokenForm->createView()]); ['form' => $tokenForm->createView()]);
} }
} else { } else {
$userToken = $tokenForm->get('user_token')->getData(); $userToken = $tokenForm->get('user_token')->getData();
$user = $app->getEntityManager()
->getRepository('Sikofitt:User') $user = $this->getDoctrine()
->getRepository('SikofittDoughnutWeddingBundle:User')
->getUserByUserToken($userToken); ->getUserByUserToken($userToken);
if (null === $user) { if (null === $user) {
$tokenForm->get('user_token') $tokenForm->get('user_token')
->addError(new FormError('Token is invalid.')); ->addError(new FormError('Token is invalid.'));
} else { } else {
$app->session()->set('user', $user); $request->getSession()->set('user', $user);
} }
return $app->render('form/token.html.twig', return $this->render('form/token.html.twig',
['form' => $tokenForm->createView()]); ['form' => $tokenForm->createView()]);
} }
} else { } else {
return $app->render('form/token.html.twig', return $this->render('form/token.html.twig',
['form' => $tokenForm->createView()]); ['form' => $tokenForm->createView()]);
} }
} }
return $app->render('form/token.html.twig', ['form' => $tokenForm->createView()]); return $this->render('form/token.html.twig', ['form' => $tokenForm->createView()]);
} else { } else {
// Token has been included. // Token has been included.
$app->session()->remove('user'); $request->getSession()->remove('user');
$tokenForm = $app->getFormFactory()->create(UserTokenType::class); $tokenForm = $this->get('form.factory')->create(UserTokenType::class);
//$user = $app->getEntityManager()->getRepository('Sikofitt:User')->getUserByUserToken($token); //$user = $app->getEntityManager()->getRepository('Sikofitt:User')->getUserByUserToken($token);
$user = $app->getEntityManager()->getRepository('Sikofitt:User')->findOneBy(['userToken' => $token]); $user = $this->getDoctrine()->getRepository('SikofittDoughnutWeddingBundle:User')->findOneBy(['userToken' => $token]);
if (null !== $user) { if (null !== $user) {
$app->session()->set('user', $user); $request->getSession()->set('user', $user);
return $app->render('user/index.html.twig'); return $this->render('user/index.html.twig');
} else { } else {
return new StreamedResponse(function () use ($app, $tokenForm, $token) { return new StreamedResponse(function () use ($tokenForm, $token) {
$tokenForm->get('user_token')->setData($token); $tokenForm->get('user_token')->setData($token);
$tokenForm->get('user_token')->addError(new FormError('Invalid token.')); $tokenForm->get('user_token')->addError(new FormError('Invalid token.'));
print $app->renderView('form/token.html.twig', ['form' => $tokenForm->createView()]); print $this->renderView('form/token.html.twig', ['form' => $tokenForm->createView()]);
}); });
} }
} }
} }
public function indexAction(Request $request, \Kernel $app) /**
* @Route("/user", name="user_index")
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function indexAction(Request $request)
{ {
if ($app->session()->has('user')) {
//if ($request->getSession()->has('user')) {
return new JsonResponse( return new JsonResponse(
[ [
'request' => $request->request->all(), 'request' => $request->request->all(),
'server' => $request->server->all(), 'server' => $request->server->all(),
'headers' => $request->headers->all(), 'headers' => $request->headers->all(),
'session' => $app->getSession()->get('user'), 'session' => $request->getSession()->all(),
'token' => (string) new TokenGenerator(), 'token' => (string) new TokenGenerator(),
] ]
); );
} // }
} }
public function loginAction(Request $request, \Kernel $app) public function loginAction(Request $request)
{ {
if ($app->session()->has('user')) { if ($app->session()->has('user')) {
//return $app->redirect($app->url('rsvp_edit')); //return $app->redirect($app->url('rsvp_edit'));

View File

@ -21,7 +21,7 @@
namespace Sikofitt\DoughnutWeddingBundle\Entity; namespace Sikofitt\DoughnutWeddingBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface; use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
@ -30,7 +30,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\UserRepository") * @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\UserRepository")
* @ORM\Table(name="users") * @ORM\Table(name="users")
*/ */
class User implements UserInterface class User extends \FOS\UserBundle\Model\User
{ {
const KATRINA_SIDE = 'Katrina'; const KATRINA_SIDE = 'Katrina';
@ -43,7 +43,7 @@ class User implements UserInterface
* *
* @var int * @var int
*/ */
private $id; protected $id;
/** /**
* @ORM\Column(name="first_name", type="string", length=255, nullable=false) * @ORM\Column(name="first_name", type="string", length=255, nullable=false)
@ -65,31 +65,31 @@ class User implements UserInterface
*/ */
private $family = false; private $family = false;
//* @Assert\Choice(choices="{self::KATRINA_SIDE, self::ERIC_SIDE}", multiple=false)
/** /**
* @ORM\Column(type="string", name="family_side", nullable=true) * @ORM\Column(type="string", name="family_side", nullable=true)
* @Assert\Choice(choices="{self::KATRINA_SIDE, self::ERIC_SIDE}", multiple=false)
* *
* @var null|string * @var null|string
*/ */
private $familySide = null; private $familySide = null;
/** /*
* @ORM\Column(name="email", type="string", length=255) * @ORM\Column(name="email", type="string", length=255)
* @Assert\Email(strict=true, checkHost=true, checkMX=true) * @Assert\Email(strict=true, checkHost=true, checkMX=true)
*/
private $email;
/** protected $email;
*/
/*
* @var string * @var string
* @ORM\Column(name="password", type="string", length=255)) * @ORM\Column(name="password", type="string", length=255))
*
protected $password;
*/ */
private $password; /*
/**
* @var string * @var string
*
protected $plainPassword;
*/ */
private $plainPassword;
/** /**
* @var string * @var string
* @ORM\Column(name="reset_token", type="string", length=255, nullable=true) * @ORM\Column(name="reset_token", type="string", length=255, nullable=true)
@ -107,6 +107,7 @@ class User implements UserInterface
* @ORM\OneToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\Rsvp", inversedBy="user", cascade={"persist"}) * @ORM\OneToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\Rsvp", inversedBy="user", cascade={"persist"})
*/ */
private $rsvp; private $rsvp;
/** /**
* @ORM\Column(type="datetime", name="created") * @ORM\Column(type="datetime", name="created")
*/ */
@ -117,12 +118,282 @@ class User implements UserInterface
*/ */
private $updated = null; private $updated = null;
/**
* @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
*/
private $facebookId;
private $facebookAccessToken;
/**
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/
private $googleId;
private $googleAccessToken;
/**
* @ORM\Column(name="amazon_id", type="string", length=255, nullable=true)
*/
private $amazonId;
private $amazonAccessToken;
/**
* @ORM\Column(name="instagram_id", type="string", length=255, nullable=true)
*/
private $instagramId;
private $instagramAccessToken;
/**
* @ORM\Column(name="twitter_id", type="string", length=255, nullable=true)
*/
private $twitterId;
private $twitterAccessToken;
/**
* @ORM\Column(name="windows_id", type="string", length=255, nullable=true)
*/
private $windowsId;
private $windowsAccessToken;
/**
* @ORM\Column(name="yahoo_id", type="string", length=255, nullable=true)
*/
private $yahooId;
private $yahooAccessToken;
/**
* @return mixed
*/
public function getAmazonId() {
return $this->amazonId;
}
/**
* @param mixed $amazonId
* @return User
*/
public function setAmazonId($amazonId) {
$this->amazonId = $amazonId;
return $this;
}
/**
* @return mixed
*/
public function getAmazonAccessToken() {
return $this->amazonAccessToken;
}
/**
* @param mixed $amazonAccessToken
* @return User
*/
public function setAmazonAccessToken($amazonAccessToken) {
$this->amazonAccessToken = $amazonAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getFacebookId() {
return $this->facebookId;
}
/**
* @param mixed $facebookId
* @return User
*/
public function setFacebookId($facebookId) {
$this->facebookId = $facebookId;
return $this;
}
/**
* @return mixed
*/
public function getFacebookAccessToken() {
return $this->facebookAccessToken;
}
/**
* @param mixed $facebookAccessToken
* @return User
*/
public function setFacebookAccessToken($facebookAccessToken) {
$this->facebookAccessToken = $facebookAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getGoogleId() {
return $this->googleId;
}
/**
* @param mixed $googleId
* @return User
*/
public function setGoogleId($googleId) {
$this->googleId = $googleId;
return $this;
}
/**
* @return mixed
*/
public function getGoogleAccessToken() {
return $this->googleAccessToken;
}
/**
* @param mixed $googleAccessToken
* @return User
*/
public function setGoogleAccessToken($googleAccessToken) {
$this->googleAccessToken = $googleAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getInstagramId() {
return $this->instagramId;
}
/**
* @param mixed $instagramId
* @return User
*/
public function setInstagramId($instagramId) {
$this->instagramId = $instagramId;
return $this;
}
/**
* @return mixed
*/
public function getInstagramAccessToken() {
return $this->instagramAccessToken;
}
/**
* @param mixed $instagramAccessToken
* @return User
*/
public function setInstagramAccessToken($instagramAccessToken) {
$this->instagramAccessToken = $instagramAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getTwitterId() {
return $this->twitterId;
}
/**
* @param mixed $twitterId
* @return User
*/
public function setTwitterId($twitterId) {
$this->twitterId = $twitterId;
return $this;
}
/**
* @return mixed
*/
public function getTwitterAccessToken() {
return $this->twitterAccessToken;
}
/**
* @param mixed $twitterAccessToken
* @return User
*/
public function setTwitterAccessToken($twitterAccessToken) {
$this->twitterAccessToken = $twitterAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getWindowsId() {
return $this->windowsId;
}
/**
* @param mixed $windowsId
* @return User
*/
public function setWindowsId($windowsId) {
$this->windowsId = $windowsId;
return $this;
}
/**
* @return mixed
*/
public function getWindowsAccessToken() {
return $this->windowsAccessToken;
}
/**
* @param mixed $windowsAccessToken
* @return User
*/
public function setWindowsAccessToken($windowsAccessToken) {
$this->windowsAccessToken = $windowsAccessToken;
return $this;
}
/**
* @return mixed
*/
public function getYahooId() {
return $this->yahooId;
}
/**
* @param mixed $yahooId
* @return User
*/
public function setYahooId($yahooId) {
$this->yahooId = $yahooId;
return $this;
}
/**
* @return mixed
*/
public function getYahooAccessToken() {
return $this->yahooAccessToken;
}
/**
* @param mixed $yahooAccessToken
* @return User
*/
public function setYahooAccessToken($yahooAccessToken) {
$this->yahooAccessToken = $yahooAccessToken;
return $this;
}
public function __construct() public function __construct()
{ {
if (null === $this->created) { if (null === $this->created) {
$this->created = new \DateTime('now'); $this->created = new \DateTime('now');
} }
$this->updated = new \DateTime('now'); $this->updated = new \DateTime('now');
parent::__construct();
} }
/** /**
@ -188,9 +459,7 @@ class User implements UserInterface
*/ */
public function getUsername() public function getUsername()
{ {
$email = explode('@', $this->email); return $this->username;
return $email[0];
} }
/** /**
@ -298,7 +567,7 @@ class User implements UserInterface
* *
* @return User * @return User
*/ */
public function setPlainPassword(string $plainPassword): User public function setPlainPassword($plainPassword): User
{ {
$this->plainPassword = $plainPassword; $this->plainPassword = $plainPassword;
@ -396,11 +665,11 @@ class User implements UserInterface
/** /**
* Set rsvp. * Set rsvp.
* *
* @param \Sikofitt\App\Entity\Rsvp $rsvp * @param Rsvp $rsvp
* *
* @return User * @return User
*/ */
public function setRsvp(\Sikofitt\App\Entity\Rsvp $rsvp = null) public function setRsvp(Rsvp $rsvp = null)
{ {
$this->rsvp = $rsvp; $this->rsvp = $rsvp;
@ -410,7 +679,7 @@ class User implements UserInterface
/** /**
* Get rsvp. * Get rsvp.
* *
* @return \Sikofitt\App\Entity\Rsvp * @return Rsvp
*/ */
public function getRsvp() public function getRsvp()
{ {

View File

@ -0,0 +1,30 @@
<?php
namespace Sikofitt\DoughnutWeddingBundle\Form;
use FOS\UserBundle\Form\Type\RegistrationFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('first_name')
->add('last_name');
}
public function configureOptions(OptionsResolver $resolver)
{
}
public function getParent() {
return RegistrationFormType::class;
}
public function getBlockPrefix()
{
return 'sikofitt_doughnut_wedding_bundle_registration_type';
}
}

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace Sikofitt\App\Repository; namespace Sikofitt\DoughnutWeddingBundle\Repository;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;

View File

@ -18,11 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace Sikofitt\App\Repository; namespace Sikofitt\DoughnutWeddingBundle\Repository;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query; use Doctrine\ORM\Query;
use Sikofitt\App\Entity\User; use Sikofitt\DoughnutWeddingBundle\Entity\User;
use Sikofitt\Security\TokenGenerator; use Sikofitt\Security\TokenGenerator;
use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validation;

View File

@ -1 +1,7 @@
Hello World! {% extends "::base.html.twig" %}
{% block title %}SikofittDoughnutWeddingBundle:Default:index{% endblock %}
{% block body %}
<h1>Welcome to the Default:index page</h1>
{% endblock %}

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace Sikofitt\Security; namespace Sikofitt\DoughnutWeddingBundle\Security;
use ParagonIE_Sodium_Compat as SodiumCompat; use ParagonIE_Sodium_Compat as SodiumCompat;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface; use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;

View File

@ -11,7 +11,6 @@ class DefaultControllerTest extends WebTestCase
$client = static::createClient(); $client = static::createClient();
$crawler = $client->request('GET', '/'); $crawler = $client->request('GET', '/');
$this->assertContains('Hello World', $client->getResponse()->getContent());
} }
} }