我已经根据其文档在 SonataUserBundle 中使用 FOSUserBundle 实现了 FOSFacebookBundle。
config.yml :
fos_facebook:
alias: facebook
app_id: xxxxxxxx597242
secret: xxxxxxxxxxxxxxxxxxxx2a6e7
cookie: true
permissions: [email, user_birthday, user_location]
services:
fos_facebook.user.login:
class: Webmuch\UserBundle\Security\User\Provider\FacebookProvider
arguments:
facebook: "@fos_facebook.api"
userManager: "@fos_user.user_manager"
validator: "@validator"
security.yml:
providers:
chain_provider:
chain:
providers: [fos_userbundle,fos_facebook_provider]
fos_userbundle:
id: fos_user.user_provider.username_email
fos_facebook_provider:
id: fos_facebook.user.login
firewalls:
main:
pattern: ^/
fos_facebook:
app_url: "https://developers.facebook.com/apps/xxxxxxxx597242"
server_url: "http://localhost/Mysite/web/app_dev.php/"
login_path: /login
check_path: /login_check
provider: fos_facebook_provider
default_target_path: /
form_login:
provider: fos_userbundle
login_path: /login
use_forward: false
check_path: /login_check
failure_path: null
logout:
path: /logout
target: /
anonymous: true
base.html.twig:
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}
{{ facebook_login_button({'autologoutlink': true}) }}
{% block javascripts %}
<script>
function goLogIn(){
window.location.href = "{{ path('fos_facebook_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
setTimeout(goLogIn, 500);
} else {
window.location.href = "{{ path('fos_user_security_logout') }}";
}
});
}
}
</script>
{% endblock %}
我的 Facebook 提供者和用户实体是根据文档设置的。
它工作得很好,但现在用新版本更新后,在我的网站上进行身份验证后登录成功,但是当我点击 Facebook 注销按钮时,它现在只是 Facebook 注销,而在我的网站中我仍然处于登录状态,即它不会破坏我的站点身份验证会话。
我不知道我做错了什么。