亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Symfony 5 不斷從注冊路由重定向

Symfony 5 不斷從注冊路由重定向

PHP
慕婉清6462132 2023-07-21 15:42:11
我正在嘗試構建一個登錄頁面,在我想登錄用戶后它就可以工作了,所以我使用了 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 }
查看完整描述

1 回答

?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

您似乎在樹枝表單上缺少 csrf_token 隱藏字段,如您提供的 Symfony 文檔鏈接中所述:如何構建登錄表單

??<input?type="hidden"?name="_csrf_token"
???????????value="{{?csrf_token('authenticate')?}}"
????>

盡管我不推薦它,但如果您的應用程序不重要,另一種解決方案是禁用 csrf_checking - 只需從 AuthAuthenticator 中刪除所有提及 CSRF 的內容即可。


查看完整回答
反對 回復 2023-07-21
  • 1 回答
  • 0 關注
  • 125 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號