views:

31

answers:

2

Hi, I'm using symfony 1.4 and the sfGuardDoctrinePlugin, I've got it installed and setup fine but I have the following problem:

If I login as an admin and update the permissions for a user, that user must logout then login again before having the newly added credential/permission.

Is there a way around this?

I'm not sure how easy this would be to fix. When a user logs in I think their credentials are added to their session attributes there and then. So when the admin updates their credentials their session still holds the old credentials. This means any call to hasCredential isn't "live".

Thanks

A: 

This would add extra queries to each and every request to your application. You could force update of the credentials by $user->getSfGuardUser()->refresh(true), which would reload the entity and all its relations (and thus its permissions).

bouke
You could lessen the impact by only doing this on, say, one in every 10 page loads: if (1 == rand(1,10)) { $user->getSfGuardUser()->refresh(true); } This would cut down the impact significantly. The consequence would be a short delay between the credential change and the updated permissions, but there would be no need to log out.
lonesomeday
A: 

Thanks for your answer, I've modified the processForm function of the sfGuardUser module's actions class.

If I login and change my own permissions, the session is updated there and then.

My problem is that if I edit the user permissions of another user, I would need to edit their session data. To solve this I enabled database sessions, so I now have sessions saving there instead of to file. So my next problem is how to isolate the session for the other user.

The sessions database has the following columns: sess_id, sess_data, sess_time.

sess_data is serialized and that is what I would need to update.

But I think symfony updates the session ids quite often and it would be hard to always isolate the correct session for the other user.

I think that it would also be slow to try and unserialize, check user_id then reserialize the data. I would need a user_id column I think.

Del1