I'm using a JDBC realm for authentication and authorization. When I remove a role from a user in the DB, the changes are not reflected immediately in the application, only at the next user login. Is it possible that role开发者_开发知识库 changes take effect immediately? I know I have to put this logic in the application itself, but I don't know how to apply this changes to a specific user while he's logged in. I'm using GF 3.1.
There are no API-provided ways for this. Your best bet is to wrap the logged-in user (the UserPrincipal
) in your own User
model object (can be as good a (JPA) entity of the very same table) which allows changing the role and then collect all logged-in users in some static/application-wide set/map with help of a Filter
and HttpSessionListener
. Finally, in the admin panel, just check if the User
is there in the set/map then get and alter it accordingly. It'll be reflected immediately for the actual enduser.
Related questions
- How to listen on realm events?
- How to check which users are all logged-in?
精彩评论