Added the possibility to register
This commit is contained in:
parent
1d82e93176
commit
a454dc7483
@ -14,8 +14,11 @@
|
|||||||
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'a-magiarol-roviden' }) }}">A Mágiáról röviden</a></li>
|
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'a-magiarol-roviden' }) }}">A Mágiáról röviden</a></li>
|
||||||
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'rendek' }) }}">Rendek</a></li>
|
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'rendek' }) }}">Rendek</a></li>
|
||||||
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'a-regiek' }) }}">A régiek</a></li>
|
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'a-regiek' }) }}">A régiek</a></li>
|
||||||
<li><a href="">Archívum</a></li>
|
{% if app.user %}
|
||||||
<li><a href="">Ajánlott oldalak</a></li>
|
<li><a href="{{ path('KekRozsakSecurityBundle_logout') }}">Kijelentkezés</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><a href="{{ path('KekRozsakSecurityBundle_registration') }}">Jelentkezés</a></li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
|
@ -41,6 +41,7 @@ security:
|
|||||||
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/cikk/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
- { path: ^/cikk/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
|
- { path: ^/jelentkezes, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||||
- { path: ^/, roles: [ IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED ] }
|
- { path: ^/, roles: [ IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED ] }
|
||||||
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
|
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
|
||||||
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
|
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
|
||||||
|
@ -4,11 +4,12 @@ namespace KekRozsak\FrontBundle\Entity;
|
|||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KekRozsak\FrontBundle\Entity\User
|
* KekRozsak\FrontBundle\Entity\User
|
||||||
*/
|
*/
|
||||||
class User implements UserInterface
|
class User implements UserInterface, AdvancedUserInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var integer $id
|
* @var integer $id
|
||||||
@ -192,6 +193,11 @@ class User implements UserInterface
|
|||||||
return $this->roles->toArray();
|
return $this->roles->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRolesCollection()
|
||||||
|
{
|
||||||
|
return $this->roles;
|
||||||
|
}
|
||||||
|
|
||||||
public function eraseCredentials()
|
public function eraseCredentials()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -254,4 +260,51 @@ class User implements UserInterface
|
|||||||
{
|
{
|
||||||
return $this->forum_posts;
|
return $this->forum_posts;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @var KekRozsak\FrontBundle\Entity\User
|
||||||
|
*/
|
||||||
|
private $accepted_by;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set accepted_by
|
||||||
|
*
|
||||||
|
* @param KekRozsak\FrontBundle\Entity\User $acceptedBy
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setAcceptedBy(\KekRozsak\FrontBundle\Entity\User $acceptedBy = null)
|
||||||
|
{
|
||||||
|
$this->accepted_by = $acceptedBy;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get accepted_by
|
||||||
|
*
|
||||||
|
* @return KekRozsak\FrontBundle\Entity\User
|
||||||
|
*/
|
||||||
|
public function getAcceptedBy()
|
||||||
|
{
|
||||||
|
return $this->accepted_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAccountNonExpired()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAccountNonLocked()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isCredentialsNonExpired()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEnabled()
|
||||||
|
{
|
||||||
|
return ($this->accepted_by !== null);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
namespace KekRozsak\FrontBundle\Form\Extension;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractTypeExtension;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormViewInterface;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class HelpMessageTypeExtension extends AbstractTypeExtension
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->setAttribute('help', $options['help']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildView(FormViewInterface $view, FormInterface $form, array $options)
|
||||||
|
{
|
||||||
|
$view->setVar('help', $form->getAttribute('help'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultOptions()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'help' => null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtendedType()
|
||||||
|
{
|
||||||
|
return 'field';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
61
src/KekRozsak/FrontBundle/Form/Type/UserType.php
Normal file
61
src/KekRozsak/FrontBundle/Form/Type/UserType.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
namespace KekRozsak\FrontBundle\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class UserType extends AbstractType
|
||||||
|
{
|
||||||
|
protected $_registration;
|
||||||
|
|
||||||
|
public function __construct($registration)
|
||||||
|
{
|
||||||
|
$this->_registration = $registration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->add('username', null, array(
|
||||||
|
'label' => 'Felhasználónév',
|
||||||
|
'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Jelszavadhoz hasonlóan kezeld bizalmasan! Jelentkezés után nem lehet megváltoztatni!',
|
||||||
|
));
|
||||||
|
$builder->add('password', 'repeated', array(
|
||||||
|
'type' => 'password',
|
||||||
|
'second_name' => 'confirm',
|
||||||
|
'invalid_message' => 'A két jelszó nem egyezik meg!',
|
||||||
|
'options' => array(
|
||||||
|
'label' => 'Jelszó',
|
||||||
|
'help' => 'Ezt fogod használni az oldalra való bejelentkezéshez. Soha ne add meg senkinek!',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
$builder->add('email', null, array(
|
||||||
|
'label' => 'E-mail cím',
|
||||||
|
));
|
||||||
|
$builder->add('displayName', null, array(
|
||||||
|
'label' => 'Név',
|
||||||
|
'help' => 'Ezen a néven fog szólítani a közösség. Bármikor megváltoztathatod, de az egyértelműség kedvéért ezt mindig jelezd a többiek felé!',
|
||||||
|
));
|
||||||
|
$builder->add('agree', 'checkbox', array(
|
||||||
|
'property_path' => false,
|
||||||
|
'label' => ' ',
|
||||||
|
'help' => 'A Jelentkezés gomb megnyomásával kijelentem, hogy a Kék Rózsa okkultista kör Házirendjét elolvastam, és azt felvételem esetén magamra nézve teljes mértékben elfogadom.',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'user';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultOptions()
|
||||||
|
{
|
||||||
|
$opts = array(
|
||||||
|
'data_class' => 'KekRozsak\FrontBundle\Entity\User',
|
||||||
|
);
|
||||||
|
if ($this->_registration)
|
||||||
|
$opts['validation_groups'] = array('registration');
|
||||||
|
|
||||||
|
return $opts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,10 @@ KekRozsak\FrontBundle\Entity\User:
|
|||||||
targetEntity: ForumPost
|
targetEntity: ForumPost
|
||||||
mappedBy: created_by
|
mappedBy: created_by
|
||||||
fetch: EXTRA_LAZY
|
fetch: EXTRA_LAZY
|
||||||
|
manyToOne:
|
||||||
|
accepted_by:
|
||||||
|
targetEntity: User
|
||||||
|
fetch: EXTRA_LAZY
|
||||||
manyToMany:
|
manyToMany:
|
||||||
roles:
|
roles:
|
||||||
targetEntity: Role
|
targetEntity: Role
|
||||||
|
@ -11,3 +11,7 @@ services:
|
|||||||
doctrine: @doctrine
|
doctrine: @doctrine
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
form.type_extension.help_message:
|
||||||
|
class: KekRozsak\FrontBundle\Form\Extension\HelpMessageTypeExtension
|
||||||
|
tags:
|
||||||
|
- { name: "form.type_extension", alias: "field" }
|
||||||
|
29
src/KekRozsak/FrontBundle/Resources/config/validation.yml
Normal file
29
src/KekRozsak/FrontBundle/Resources/config/validation.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
KekRozsak\FrontBundle\Entity\User:
|
||||||
|
constraints:
|
||||||
|
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
|
||||||
|
fields: username
|
||||||
|
message: "Ez a felhasználónév már foglalt. Kérlek, válassz egy másikat!"
|
||||||
|
groups: [ registration ]
|
||||||
|
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
|
||||||
|
fields: email
|
||||||
|
message: "Ez az e-mail cím már foglalt. Kérlek, válassz egy másikat!"
|
||||||
|
groups: [ registration ]
|
||||||
|
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
|
||||||
|
fields: display_name
|
||||||
|
message: "Ez a név már foglalt. Kérlek, válassz egy másikat!"
|
||||||
|
groups: [ registration ]
|
||||||
|
properties:
|
||||||
|
username:
|
||||||
|
- NotBlank: { groups: [ registration ] }
|
||||||
|
password:
|
||||||
|
- NotBlank: { groups: [ registration ] }
|
||||||
|
email:
|
||||||
|
- NotBlank: { groups: [ registration ] }
|
||||||
|
- Email: { groups: [ registration ] }
|
||||||
|
registered_at:
|
||||||
|
- NotBlank: ~
|
||||||
|
- Type: \DateTime
|
||||||
|
display_name:
|
||||||
|
- NotBlank: { groups: [ registration ] }
|
||||||
|
KekRozsak\FrontBundle\Form\Type\UserType:
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
{% block field_row %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ form_label(form) }}</td>
|
||||||
|
<td>{{ form_widget(form) }}</td>
|
||||||
|
<td>
|
||||||
|
{{ help }}
|
||||||
|
</td>
|
||||||
|
<td>{{ form_errors(form) }}</td>
|
||||||
|
</td>
|
||||||
|
{% endblock %}
|
@ -4,6 +4,10 @@ namespace KekRozsak\SecurityBundle\Controller;
|
|||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\Security\Core\SecurityContext;
|
use Symfony\Component\Security\Core\SecurityContext;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
use KekRozsak\FrontBundle\Entity\User;
|
||||||
|
use KekRozsak\FrontBundle\Form\Type\UserType;
|
||||||
|
|
||||||
class DefaultController extends Controller
|
class DefaultController extends Controller
|
||||||
{
|
{
|
||||||
@ -27,4 +31,37 @@ class DefaultController extends Controller
|
|||||||
'error' => $error,
|
'error' => $error,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registrationAction(Request $request)
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
$form = $this->createForm(new UserType(true), $user);
|
||||||
|
|
||||||
|
if ($request->getMethod() == 'POST')
|
||||||
|
{
|
||||||
|
$form->bindRequest($request);
|
||||||
|
if ($form->isValid(array('registration')))
|
||||||
|
{
|
||||||
|
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
|
||||||
|
$roleRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Role');
|
||||||
|
$regRole = $roleRepo->findOneByName('ROLE_REGISTERED');
|
||||||
|
$user->addRole($regRole);
|
||||||
|
$user->setRegisteredAt(new \DateTime('now'));
|
||||||
|
$em = $this->getDoctrine()->getEntityManager();
|
||||||
|
$em->persist($user);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
return $this->redirect($this->generateUrl('KekRozsakSecurityBundle_reg_success'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('KekRozsakSecurityBundle:Default:registration.html.twig', array(
|
||||||
|
'form' => $form->createView(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registrationSuccessAction()
|
||||||
|
{
|
||||||
|
return $this->render('KekRozsakSecurityBundle:Default:registration_success.html.twig', array());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,3 +8,13 @@ KekRozsakSecurityBundle_login_check:
|
|||||||
|
|
||||||
KekRozsakSecurityBundle_logout:
|
KekRozsakSecurityBundle_logout:
|
||||||
pattern: /logout
|
pattern: /logout
|
||||||
|
|
||||||
|
KekRozsakSecurityBundle_registration:
|
||||||
|
pattern: /jelentkezes
|
||||||
|
defaults:
|
||||||
|
_controller: KekRozsakSecurityBundle:Default:registration
|
||||||
|
|
||||||
|
KekRozsakSecurityBundle_reg_success:
|
||||||
|
pattern: /most-varj
|
||||||
|
defaults:
|
||||||
|
_controller: KekRozsakSecurityBundle:Default:registrationSuccess
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
{# vim: ft=htmljinja: #}
|
||||||
|
{% extends '::main_template.html.twig' %}
|
||||||
|
{% form_theme form 'KekRozsakFrontBundle:Form:user_form.html.twig' %}
|
||||||
|
{% block title %} - Regisztráció {% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<h3>Jelentkezés</h3>
|
||||||
|
<p>Az alábbi űrlap kitöltésével jelentkezhetsz a Kék Rózsa okkultista kör tagjai közé. Kérünk, hogy jelentkezés előtt figyelmesen olvasd el a <a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'rolunk' }) }}">Rólunk</a> menüpont szövegét, különös tekintettel a Házirendre.</p>
|
||||||
|
<p>A jelentkezés NEM jár automatikus tagsággal. A Házirend szerint a Vének jogot formálhatnak arra, hogy a jelentkezésedet elutasítsák, vagy próbáknak vessenek alá, mielőtt a tagok közé fogadnak.</p>
|
||||||
|
<p><strong>FONTOS!</strong> Aki a régi fórumon írt bármilyen bejegyzést, az már regisztrálva van ezen az oldalon is! Ez esetben kérlek lépjetek kapcsolatba velem <a href="http://www.facebook.com/Polesz" target="_blank">Facebookon</a> vagy e-mailben a <a href="jelentkezes@blueroses.hu">jelentkezes@blueroses.hu</a> címen!</p>
|
||||||
|
<form method="post" action="{{ path('KekRozsakSecurityBundle_registration') }}">
|
||||||
|
<table>
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
</table>
|
||||||
|
<button type="submit">Jelentkezés</button>
|
||||||
|
{% endblock content %}
|
@ -0,0 +1,5 @@
|
|||||||
|
{% extends '::main_template.html.twig' %}
|
||||||
|
{% block title %} - Sikeres regisztráció{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
A regisztrációd sikeres volt.
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user