我正在嘗試構建一個登錄頁面,在我想登錄用戶后它就可以工作了,所以我使用了 make: Auth 似乎但現在 Symfony 5 不斷從注冊路由重定向到登錄,而不先將用戶保存在數據庫中,當提交表單時,它在我運行 make auth cmd 之前就可以工作大部分代碼與用戶身份驗證有關這是我使用的指南https://symfony.com/doc/current/security/form_login_setup.html在 Symfony 文檔上我想這就是它搞砸的原因當您提交表單時,LoginFormAuthenticator 將攔截請求,從表單中讀取電子郵件(或您正在使用的任何字段)和密碼,找到 User 對象,驗證 CSRF 令牌并檢查密碼security: encoders: App\Entity\User: algorithm: auto providers: users: entity: class: App\Entity\User property: Username firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: access_denied_handler: App\Security\AccessDeniedHandler anonymous: false lazy: true provider: users form_login: login_path: app_login check_path: app_login guard: authenticators: - App\Security\AuthAuthenticator logout: path: app_logout # where to redirect after logout # target: app_any_route # activate different ways to authenticate # https://symfony.com/doc/current/security.html#firewalls-authentication # https://symfony.com/doc/current/security/impersonating_user.html # switch_user: true # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: # - { path: ^/admin, roles: ROLE_ADMIN } # - { path: ^/profile, roles: ROLE_USER }
Symfony 5 不斷從注冊路由重定向
慕婉清6462132
2023-07-21 15:42:11