user2667066
user2667066

Reputation: 2109

Web2py: stop guest users from changing password

I'm setting up a demo web2py site to show a few people. I'm going to set up a 'guest' account with a simple password. How can I stop someone logged in as 'guest' from changing this password, while allowing other (non-guest) users to change their password if they want to.

Upvotes: 0

Views: 72

Answers (1)

Anthony
Anthony

Reputation: 25536

Right after defining the Auth object, you can do something like the following:

auth = Auth(db)
if auth.user and auth.user.username == 'guest':
    auth.settings.actions_disabled = ['reset_password', 'request_reset_password',
                                      'change_password', 'profile']

If login is via email address rather than username, then the second condition above would instead be auth.user.email == guest_email_address (fill in the actual email address of the guest account).

Upvotes: 1

Related Questions