Skip to content

Instantly share code, notes, and snippets.

@tazjel
Forked from rochacbruno/new_user.py
Created January 15, 2012 05:54
Show Gist options
  • Save tazjel/1614625 to your computer and use it in GitHub Desktop.
Save tazjel/1614625 to your computer and use it in GitHub Desktop.
create new web2py users
def new_user(first_name, last_name, email, passw):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
first_name=first_name,
last_name=last_name,
email = email,
password = crypt_pass
)
return id_user
## USAGE ##
new_id = new_user('someone', 'smith', '[email protected]', '123456')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment