UserService retrieves wrong user after logout

2019-08-17 06:49发布

I get CurrentUser from UserService

 UserServiceFactory.getUserService().getCurrentUser().getEmail()

It works when. But when I logout, UserService still return same email.

2条回答
【Aperson】
2楼-- · 2019-08-17 07:42

That answers everything. It seems that though you might have already logged out of google service, your browser was still maintaining a cookie for google service. That's why it was throwing the same user email again..

查看更多
爷的心禁止访问
3楼-- · 2019-08-17 07:45

Assuming you're logging in by the usual means for GAE, your browser will end up with two session cookies - one for Google and one for the app.

If you also log out by the usual means (the logout URL from create_logout_url), then both cookies are deleted.

However, if the user browses away from your app to some other Google service and logs out of Google from there, then the cookie for your app isn't deleted (at least, not for me in Firefox). I'm not sure that it even can be - once the browser is away from your app, quite possibly it won't allow Google sites to touch your app's cookies in any way.

The fix should be to provide a logout link in your app, and for the user to log out using that. If you're already doing that, then I don't know what the problem is...

查看更多
登录 后发表回答