That is how I do it. As far as I know, setting registration_key to
'disabled' is the only way for web2py to deny a log in for someone using
Auth. When I need to set this or check it, I just wrap the code into a
generic is_disabled() method to do the checking in case a better way
presents it self in the future, I only need to change that method.
You could do something like this at the end of your model:
db.auth_user.is_enabled = lambda r: r.registration_key != 'disabled'
Then whenever you need to check if a user account is enabled:
rows = db().select(db.auth_user.ALL)
for row in rows:
if db.auth_user.is_enabled(row):
# account is enabled
else:
# account is disabled
By the way, I noticed that you used 'users[0]' in your code. I don't know if
you are aware of this, but web2py has a cleaner method of selecting a single
row:
user = db(db.auth_user.id==userId).select().first()
Using first() is the same thing as users[0], it's just a lot cleaner and
allows you to easily check for None in case there were no records found.