def signUp():
# Get data from sign up form on front-end (in JSON format)
custEntry = request.get_json()
entered_password = custEntry['password']
entered_password2 = custEntry['password2']
if entered_password == entered_password2:
# Encrypt the password entered by the user
salt = bcrypt.gensalt()
encrypted_password = bcrypt.hashpw(entered_password.encode('utf-8'), salt)
# Store the user information as a new entry (with the encrypted_password)
result = db.insert('customer', username=custEntry['username'], email=custEntry['email'], password=encrypted_password, first_name=custEntry['first_name'], last_name=custEntry['last_name'])
# Returns the user entered information
return jsonify(result)
else:
# If passwords don't match
return 'login failed', 401
# Allows a user to login to the site
评论列表
文章目录