models.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:DjStarter 作者: mijkal 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号