php - UserBundle Symfony 2 -
tried solve problem myself after 3 days, give , ask help..
receive "bad credentials." erros (details: pastebin)
here security.yml:
security: encoders: common\userbundle\entity\user: algorithm: bcrypt role_hierarchy: role_admin: role_user role_super_admin: [role_user, role_admin, role_allowed_to_switch] providers: request_users: entity: class: commonuserbundle:user property: username dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false request_security: pattern: ^/ anonymous: ~ form_login: check_path: _check_path login_path: login_page default_target_path: gemmi_start_homepage logout: path: _logout target: signup_page access_control: #- { path: ^/login, roles: is_authenticated_anonymously, requires_channel: https }
and logincontroller:
<?php namespace common\userbundle\controller; use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\response; use sensio\bundle\frameworkextrabundle\configuration\template; use sensio\bundle\frameworkextrabundle\configuration\route; use symfony\component\security\core\securitycontextinterface; use symfony\component\httpfoundation\request; class logincontroller extends controller { public function indexaction(request $request) { $session = $this->get('session'); if($request->attributes->has(securitycontextinterface::authentication_error)) { $loginerror = $request->attributes->get(securitycontextinterface::authentication_error); } else { $loginerror = $session->remove(securitycontextinterface::authentication_error); } $username = $session->get(securitycontextinterface::last_username); echo $loginerror; return $this->render('commonuserbundle::login.html.twig', array( 'loginerror' => $loginerror, 'username' => $username )); } }
also routing.yml:
login_page: path: /login defaults: { _controller: commonuserbundle:login:index } signup_page: path: /signup defaults: { _controller: commonuserbundle:login:signup } _check_path: path: /login-check _logout: path: /logout
and:
gemmi_start_homepage: path: / defaults: { _controller: gemmistartbundle:default:index }
and form:
<form method="post" action="{{ path('_check_path') }}" name="contactform" id="contactform"> <fieldset> <label for="login" accesskey="e"></label> <input name="_username" type="text" id="login" size="30" value="{{ username }}" placeholder="{% trans %} nickname {% endtrans %}" /> <br> <br> <label for="passwd" accesskey="e"></label> <input name="_password" type="password" id="passwd" size="30" value="" placeholder="{% trans %} password {% endtrans %}" /> <br> <br> <button type="submit" class="submit btn btn-send" id="submit" value="submit"> <i class="fa fa-user"></i> {% trans %} log_in {% endtrans %} </button> </fieldset> </form>
user entity: pastebin
, last 1 - userfixtures: pastebin
know there lot check can me?
did notice you're missing specific option, named firewalls:
in security.yml
file? or accidentally left out while pasting code? syntax should this:
providers: request_users: entity: class: commonuserbundle:user property: username firewalls: # firewalls definitions goes here.
i applied configuration quickly, , managed pass form. not authenticated though, did not throw me error bad credentials
. try editing file (if line indeed missing) , see happens. if not case, continue investigating problem further.
Comments
Post a Comment