Reputation: 195
I am working on a web app that uses Web2py. My auth_user table has a username field. The problem that I am facing is when I update the username of a user, auth.user.username keeps returning the old value until the user logs out and login again.
Moreover sometimes I notice that even on making a fresh db query for the given user id it returns the obsolete user name. Why does this happen?
Upvotes: 1
Views: 1431
Reputation: 25536
auth.user
is stored in the session (along with some other auth related data). This avoids having to do a db query for the user data on every request. Therefore, updating the record in the db does not update the auth.user
object in the session. If the user updates their own profile using the built in auth.profile()
functionality, then auth.user
will automatically get updated. Otherwise, you will have to update it yourself:
auth.user.update(username='my new name')
Upvotes: 3