I tried to solve this problem myself but after three days, I give up and ask for help..
I receive "Bad credentials." erros (details: pastebin)
Here is my 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 my 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 my 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 my 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
And the last one - UserFixtures: pastebin
I know there is a lot to check but can someone help me?