copied in gwaters version of users.py