-
-
Save tazjel/1614625 to your computer and use it in GitHub Desktop.
create new web2py users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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