所以在这里,我完全配置了fos& face环境。我在这两个捆绑包中一步一步地进行了教程,检查了数百次,没有任何事情......
什么问题?我的fosBundle很棒(有我自己的模特课和我自己的facebook提供者)。当我尝试通过点击着名的蓝色按钮登录Facebook时出现问题。我点击,某事正在打开,然后关闭 - >和错误(在重定向中)。 action / check_login返回任何内容。我没有对这个动作做过任何事情(像我说的那样一步一步地进行),在配置中没有提到编辑路由/ check_login。
毕竟,facebookBundle对我来说根本不起作用,因为缺乏这个动作。
某人可以帮帮我吗?
一些配置信息:
fosbundle: ~2.0@dev
facebookbundle: dev-master
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
chain_provider:
chain:
providers: [fos_userbundle, my_fos_facebook_provider]
fos_userbundle:
id: user_provider
my_fos_facebook_provider:
id: my.facebook.user # see "Example Custom User Provider using the FOS\UserBundle" chapter further down
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
public:
pattern: ^/.*
fos_facebook:
app_url: "http://www.facebook.com/apps/application.php?id=myAppId"
server_url: "http://l.local/app_dev.php/"
login_path: /login
check_path: /login_check
default_target_path: /
provider: my_fos_facebook_provider
anonymous: true
logout: true
# redirect_to_facebook_login: false
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
- { path: ^/secured/.*, role: IS_AUTHENTICATED_FULLY }
- { path: ^/facebook/, role: [ROLE_FACEBOOK] }
- { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
config.yml ....
fos_user:
db_driver: propel # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Back\UserBundle\Model\User
fos_facebook:
alias: <name>
app_id: <myNumber>
secret: <myNumber>
cookie: true
permissions: [email]
的routing.yml
fos_facebook_channel:
resource: "@FOSFacebookBundle/Resources/config/routing.xml"
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
_imagine:
resource: .
type: imagine
_security_check:
pattern: /login_check
_security_logout:
pattern: /logout
希望,这些信息足够了。
感谢。
答案 0 :(得分:1)
将FB提供程序注册为服务。在主config.yml
或捆绑services.yml
services:
my.facebook.user:
class: Demo\UserBundle\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
在security.yml
中,将facebook的check_path
参数更改为其他内容。
check_path: /login_facebook_check
并在routing.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
chain_provider:
chain:
providers: fos_user_bundle,my_fos_facebook_provider
fos_user_bundle:
id: fos_user.user_provider.username
my_fos_facebook_provider:
id: my.facebook.user
firewalls:
main:
pattern: ^/
form_login:
provider: fos_user_bundle
csrf_provider: form.csrf_provider
login_path: /login
check_path: /login_check
fos_facebook:
app_url: " xxx "
server_url: "xxx"
check_path: /login_fb_check
default_target_path: /
provider: my_fos_facebook_provider
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
我的routing.yml
demo_user:
resource: "@DemoUserBundle/Controller/"
type: annotation
prefix: /
_security_check:
pattern: /login_fb_check
_security_logout:
pattern: /logout
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile