簡體   English   中英

Symfony 6:無法登錄(沒有任何反應)

[英]Symfony 6 : Login impossible (nothing happens)

我希望你能幫助我...

當我嘗試登錄我的 Symfony 6 應用程序時,沒有任何反應。 我沒有錯誤,但它不記錄我。 它只會刷新頁面。

安全.yaml

security:
    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email

    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            security: false
            lazy: true
            provider: app_user_provider
            custom_authenticator:
                - App\Security\AppAuthenticator
            logout:
                path: app_logout
                target: login
        secured_area:
            pattern:   ^/
            form_login:
                login_path: app_login
                check_path: app_login

安全控制器::登錄

public function login(AuthenticationUtils $authenticationUtils, $errorLog = null): Response
    {
        if ($this->getUser()) {
            return $this->redirectToRoute('app_dashboard');
        }

        // get the login error if there is one
        $error = $authenticationUtils->getLastAuthenticationError();
        // last username entered by the user
        $lastUsername = $authenticationUtils->getLastUsername();

        // var_dump($errorLog);

        return $this->render('public/auth/login.html.twig', [
            'last_username' => $lastUsername, 
            'error' => $error
        ]);
    }

我的產品服務器是最新的,我可以登錄,但在開發 (127.0.0.1) 中這是不可能的。

謝謝您的幫助。

試試這個:

password_hashers:
   App\Entity\User:
      algorithm: auto

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        lazy: true
        provider: app_user_provider

看起來您在主防火牆中禁用了安全層。 嘗試刪除security: false在主防火牆中:

# security.yaml
security:
    providers:
        app_user_provider:
            entity:
                class: App\Entity\User
                property: email

    password_hashers:
        Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            # security: false # REMOVE THIS LINE
            lazy: true
            provider: app_user_provider
            custom_authenticator:
                - App\Security\AppAuthenticator
            logout:
                path: app_logout
                target: login
        secured_area:
            pattern:   ^/
            form_login:
                login_path: app_login
                check_path: app_login

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM