簡體   English   中英

Symfony私人Beta版登錄

[英]Symfony Private Beta Login

我希望在即將推出的symfony網站上設置私人Beta。 我在服務器上的文本文件中提供了一個受邀人員的電子郵件地址列表,以供檢查。我想在他們嘗試未經許可訪問該網站時向他們提供html表單。 輸入人員的電子郵件地址后,應將其重定向到主頁。 棘手的部分是,過去我使用FOSUserBundle並已使用整個帳戶登錄系統。 我應該如何解決這個問題? 使用電子郵件登錄的人還沒有帳戶,因此我不能僅在其用戶文檔中添加INVITED_USER之類的角色,因此我正在考慮嘗試在其會話中存儲其狀態,並使用symfony 2.4的allow_if表達式,但出現錯誤:

致命錯誤:C:\\ wamp \\ www \\ vendor \\ symfony \\ symfony \\ src中未捕獲的異常'Symfony \\ Component \\ Config \\ Definition \\ Exception \\ InvalidConfigurationException',消息為“ security.access_control.17”下的“無法識別的選項” allow_if” 306行上的\\ Symfony \\ Component \\ Config \\ Definition \\ ArrayNode.php

我的security.yml文件如下所示:

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        beta:
            pattern: ^/
            anonymous: ~
            form_login:
                login_path: /beta
                check_path: /beta_invite_check
                always_use_default_target_path: true
                default_target_path: /
            logout:
                path: /logout
                target: /
        main:
            pattern:  ^/
            form_login:
                check_path: /login_check
                provider: fos_userbundle
                always_use_default_target_path: false
                default_target_path: /profile
                use_referer: true
                success_handler: security.authentication.handler

            logout:
                path:   /logout
                target: /
                invalidate_session: false
            anonymous: ~

        login:
            pattern: ^/login$
            security: false

    access_control:
        - { path: ^/beta, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/account, roles: ROLE_USER}
        - { path: /_wdt/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: /_profiler/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/profile, role: ROLE_USER }
        - { path: ^/submit, role: ROLE_USER }
        - { path: ^/submissions, role: ROLE_USER }
        - { path: ^/uploadCredits, role: ROLE_USER }
        - { path: ^/transactions, role: ROLE_USER }
        - { path: ^/activity, role: ROLE_USER }
        - { path: ^/browse/join, role: ROLE_USER }
        - { path: ^/browse/follow, role: ROLE_USER }
        - { path: ^/browse/unfollow, role: ROLE_USER }
        - { path: ^/player/rating, role: ROLE_USER }
        - { path: ^/, allow_if: "'BETA_ALLOWED' == request.getSession().beta" }

有人知道為什么會這樣嗎? allow_if似乎是一個新功能,所以也許某人的捆綁軟件在其中表現不佳? 這也是我的composer.json文件,以防萬一:

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "doctrine/mongodb-odm": "1.0.*@dev",
        "doctrine/mongodb-odm-bundle": "3.0.*@dev",
        "php": ">=5.3.3",
        "symfony/symfony": "2.4.1",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "hipaway-travel/mandrill-bundle": "dev-master",
        "symfony/monolog-bundle": "2.2.*",
        "sensio/distribution-bundle": "2.2.*",
        "sensio/framework-extra-bundle": "2.2.*",
        "sensio/generator-bundle": "2.2.*",
        "jms/security-extra-bundle": "dev-master",
        "friendsofsymfony/user-bundle": "~2.0.*@dev",
        "jms/di-extra-bundle": "dev-master",
        "sonata-project/media-bundle": "2.2.*@dev",
        "sonata-project/admin-bundle": "2.2.*@dev",
        "sonata-project/core-bundle": "2.2.*@dev",
        "sonata-project/doctrine-mongodb-admin-bundle": "2.2.*@dev",
        "avalanche123/imagine-bundle": "v2.1",
        "braintree/braintree_php" : "dev-master",
        "cometcult/braintree-bundle": "dev-master",
        "paypal/rest-api-sdk-php": "dev-master",
        "kmj/paypalbridgebundle": "dev-master",
        "hwi/oauth-bundle": "0.3.*@dev",
        "cboden/Ratchet": "0.3.0",
        "react/zmq": "0.2.*"

    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "dev",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}

提前致謝!

我之前實現此方法的方式是使用邀請實體。

  1. 生成邀請碼,並通過電子郵件向用戶發送注冊表格的鏈接
  2. 僅接受包含有效邀請碼的注冊

您需要使用新的邀請字段注冊控制器操作 擴展注冊表單

基本上閱讀以下內容: https : //github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/adding_invitation_registration.md

:)

TLDR; 不用擔心首次登錄,而使用邀請系統。

暫無
暫無

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

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