Answer the question
In order to leave comments, you need to log in
Why doesn't the authorization form via email work?
I did everything according to the example
https://www.youtube.com/watch?v=3xhYwwznIWU
https://stackoverflow.com/questions/14267581/symfo...
After I send the form with email and password, it translates back to the page , no mistakes. The method that is responsible for checking does not even enter, any dump (), exit; doesn't work there. Therefore, the user will still be ANON after entering and submitting the data.
Of course, I peeped into the docks and Google
https://symfony.com/doc/current/reference/configur...
https://symfony.com/doc/current/security/form_logi... There
is data in the database.
Apparently I'm missing something.
CSRF is disabled.
user class
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepositoryInterface")
* @ORM\Table(name="`user`",indexes={@ORM\Index(name="user_search_idx", columns={"id"})})
* @ORM\HasLifecycleCallbacks()
*
* @ExclusionPolicy("none")
*/
//class User implements UserInterface
class User implements \Symfony\Component\Security\Core\User\UserInterface
{
/**
* @var UserID
*
* @ORM\Id
* @ORM\Column(type="guid", unique=true)
*
* @Groups({"list", "single"})
*/
private $id;
/**
* @var string
* @ORM\Column(type="string", length=100)
*/
private $nickname;
/**
* @var string
* @ORM\Column(type="string", unique=true)
*/
protected $nicknameCanonical;
/**
* @var string
*
* @ORM\Column(type="string", length=100, unique=true)
*/
private $email;
/**
* @var string
*
* @ORM\Column(type="string")
*/
private $password;
/**
* @var UserPlainPassword
*/
protected $plainPassword;
/**
* @var string
*
* @ORM\Column(type="string", length=100)
*/
private $salt;
/**
* @var string
* @ORM\Column(type="string", length=100, unique=true, nullable=true)
*/
private $rememberToken;
private $roles;
.... // еще простые поля по типу createdAt, deletedAt и другие
public function getUsername() : string
{
return $this->getEmail();
}
public function getRoles() : array
{
return [
'ROLE_USER'
];
}
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
admin_firewall:
anonymous: ~
form_login:
login_path: /admin/login
check_path: /admin/login/check
default_target_path: /
username_parameter: email
password_parameter: password
/**
* get authentication page
*
* @Route(
* path="admin/login",
* methods={"GET"},
* schemes={"https"},
* )
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function loginPage() : Response
{
return $this->render('admin_area/auth/login.html.twig');
}
/**
* @Route(
* path="admin/login/check",
* methods={"POST"},
* schemes={"https"},
* )
* @param Request $request
* @param AuthenticationUtils $authenticationUtils
*
* @return Response
*/
public function loginAction(Request $request, AuthenticationUtils $authenticationUtils) : Response
{
$errors = $authenticationUtils->getLastAuthenticationError();
$lastUserName = $authenticationUtils->getLastUsername();
if(null !== $errors){
return $this->render('admin/auth/login.html.twig', [
'errors' => $errors,
'lastUserName' => $lastUserName,
]);
}
return $this->render('admin/dashboard.html.twig');
}
<form method="POST" action="admin/login/check">
<input type="password" name="password" >
<input type="email" name="email" >
<button type="submit" class="btn btn-success"> LogIn </button>
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question