Mi codigo:
Controlador y metodo del login
Código PHP:
namespace PlayIBundleController;
use SymfonyBundleFrameworkBundleControllerController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentSecurityCoreSecurityContext;
class SecurityController extends Controller
{
public function loginAction()
{
$request = $this->getRequest();
$session = $request->getSession();
// obtiene el error de inicio de sesión si lo hay
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(
SecurityContext::AUTHENTICATION_ERROR
);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render(
'PlayIBundle:Security:login.html.twig',
array(
// último nombre de usuario ingresado
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
)
);
}
}
El security.yml
Código YML:
Ver original
security: encoders: Symfony\Component\Security\Core\User\User: plaintext Play\IBundle\Entity\User: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: main: entity: { class: Play\IBundle\Entity\User, property: username } firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login_firewall: pattern: /login$ security: false secured_area: pattern: ^/user/manager anonymous: ~ form_login: login_path: login check_path: login_check logout: path: _logout target: / #anonymous: ~ #http_basic: # realm: "Secured Demo Area" access_control: - { path: ^/user/manager/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/login_check$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/user/manager, roles: ROLE_USER } #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
y el routing.yml
Código YML:
Ver original
play_i_homepage: pattern: /hello/{name} defaults: { _controller: PlayIBundle:Default:index } registro: pattern: /registrarse defaults: { _controller: PlayIBundle:Default:registro } account_create: pattern: /cuenta_creada defaults: { _controller: PlayIBundle:Default:creado } login: pattern: /login defaults: {_controller: PlayIBundle:Security:login } login_check: pattern: /login_check _user_manager: pattern: /user/manager defaults: {_controller: PlayIBundle:User:Cpanel } _logout: pattern: /logout
El cookBook dice que el Login_check debe estar detras de un firewall, esa parte es la que no entiendo a que se refiere, intente hacerlo por mi mismo pero no pude por eso tube que abrir el mensaje para saber si alguien puede aclararme esta duda