def signup(self, postData):
errors = []
response = {}
#Validate form data
if not EMAIL_REGEX.match(postData['email']):
error.append('Email error')
if postData['password'] != postData['confirm_password']:
errors.append('Confirm password did not match.')
elif not PASSWORD_REGEX.match(postData['password']):
errors.append('Password must blah.')
#Compile errors and send to response messages
if errors:
response['status'] = False
response['errors'] = errors
else:
response['status'] = True
response['user'] = self.create(
email=postData['email'],
first_name=postData['first_name'],
last_name=postData['last_name'],
password=bcrypt.hashpw(postData['password'].encode('utf-8'),bcrypt.gensalt())
)
return response
评论列表
文章目录