Ребята, я новичок в Symfony 4,
Это мой security.yaml, и я намерен войти в систему, загружая пользователя из базы данных.
security:
encoders:
App\Entity\Login:
algorithm: bcrypt
providers:
db_provider:
entity:
class: App\Entity\Login
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
provider: db_provider
anonymous: ~
form_login:
login_path: login
check_path: login
default_target_path: postlogin
И это моя сущность
class Login
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type = "integer")
*/
private $id;
/**
* @ORM\Column(type = "string", length=255)
*/
private $username;
/**
* @ORM\Column(type = "string", length=255)
*/
private $email;
/**
* @ORM\Column(type = "string", length=255)
*/
private $password;
public function getId()
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
}
И это полная ошибка
Symfony \ Component \ Security \ Core \ Exception \ AuthenticationServiceException: провайдер пользователя должен возвращать объект UserInterface. в C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ security \ Core \ Authentication \ Provider \ DaoAuthenticationProvider.php: 85 Трассировка стека: # 0 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-foundation \ Session \ Storage \ NativeSessionStorage.php (142): session_start () # 1 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-foundation \ Session \ Storage \ NativeSessionStorage.php (299): Symfony \ Component \ HttpFoundation \ Session \ Storage \ NativeSessionStorage-> start () # 2 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-foundation \ Session \ Session.php (249): Symfony \ Component \ HttpFoundation \ Session \ Storage \ NativeSessionStorage-> getBag ('attributes') # 3 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-foundation \ Session \ Session.php (271): Symfony \ Component \ HttpFoundation \ Session \ Session-> getBag ('атрибуты' ) # 4 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-foundation \ Session \ Session.php (73): Symfony \ Component \ HttpFoundation \ Session \ Session-> getAttributeBag () # 5 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ security \ Http \ Firewall \ ContextListener.php (88): Symfony \ Component \ HttpFoundation \ Session \ Session-> get ('_ security_main') # 6 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ security-bundle \ Debug \ WrappedListener.php (46): Symfony \ Component \ Security \ Http \ Firewall \ ContextListener-> handle (Object (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent)) # 7 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ security-bundle \ Debug \ TraceableFirewallListener.php (35): Symfony \ Bundle \ SecurityBundle \ Debug \ WrappedListener-> handle (Object (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent)) # 8 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ security \ Http \ Firewall.php (56): Symfony \ Bundle \ SecurityBundle \ Debug \ TraceableFirewallListener-> handleRequest (Object (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent), Object (Symfony \ Component \ DependencyInjection \ Argument \ RewindableGenerator)) # 9 C: \ xampp \ htdocor \ symfony \ security-bundle \ EventListener \ FirewallListener.php (48): Symfony \ Component \ Security \ Http \ Firewall-> onKernelRequest (Object (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent)) # 10 [внутренняя функция ция]: Symfony \ Bundle \ SecurityBundle \ EventListener \ FirewallListener-> onKernelRequest (Object (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent), 'kernel.request', Object (Symfony \ Component \ HttpKernel \ Debug \ TraceableEvent) # C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ event-dispatcher \ Debug \ WrappedListener.php (104): call_user_func (массив, объект (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent), 'kernel.request', Object (Symfony \ Component \ HttpKernel \ Debug \ TraceableEventDispatcher)) # 12 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ event-dispatcher \ EventDispatcher.php (212): Symfony \ Component \ EventDispatcher \ Debug \ WrappedListener> __ invrappedListener (Объект (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent), 'kernel.request', Object (Symfony \ Component \ EventDispatcher \ EventDispatcher)) # 13 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ event-dispatcher \ EventDispatcher.php (44): Symfony \ Component \ EventDispatcher \ EventDispatcher-> doDispatch (Массив, 'kernel.request', Объект (Symfony \ Component \ HttpKernel \ Event \ GetRespons eEvent)) # 14 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ event-dispatcher \ Debug \ TraceableEventDispatcher.php (139): Symfony \ Component \ EventDispatcher \ EventDispatcher-> dispatch ('kernel.request', Object ( Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent)) # 15 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-kernel \ HttpKernel.php (125): Symfony \ Component \ EventDispatcher \ Debug \ TraceableEventDispatcher ( 'kernel.request', Объект (Symfony \ Component \ HttpKernel \ Event \ GetResponseEvent)) # 16 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-kernel \ HttpKernel.php (66): Symfony \ Component \ HttpKernel \ HttpKernel-> handleRaw (Object (Symfony \ Component \ HttpFoundation \ Request), 1) # 17 C: \ xampp \ htdocs \ Auth \ vendor \ symfony \ http-kernel \ Kernel.php (190): Symfony \ Component \ HttpKernel \ HttpKernel-> handle (Object (Symfony \ Component \ HttpFoundation \ Request), 1, true) # 18 C: \ xampp \ htdocs \ Auth \ public \ index.php (37): Symfony \ Component \ HttpKernel \ Kernel-> handle (Object (Symfony \ Component \ HttpFoundation \ Request)) # 19 {main}




Ваш логин должен реализовывать UserInterface или AdvancedUserInterface.
нравиться:
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
class User implements AdvancedUserInterface, \Serializable
{
....
}
Имейте в виду, что AdvancedUserInterface устарел для будущих версий Symfony. symfony.com/blog/…