Make sure usernames and emails are unique and message is sent to user.
This commit is contained in:
parent
730f4f2d66
commit
1574be3c07
4 changed files with 23 additions and 6 deletions
|
@ -14,8 +14,11 @@ class DataModelException(Exception):
|
|||
|
||||
def create_user(username, password, email):
|
||||
pw_hash = bcrypt.hashpw(password, bcrypt.gensalt())
|
||||
new_user = User.create(username=username, password_hash=pw_hash,
|
||||
email=email)
|
||||
try:
|
||||
new_user = User.create(username=username, password_hash=pw_hash,
|
||||
email=email)
|
||||
except Exception as ex:
|
||||
raise DataModelException(ex.message)
|
||||
return new_user
|
||||
|
||||
|
||||
|
|
Reference in a new issue