models.py 文件源码

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

项目:TalkToMe 作者: glenjantz 项目源码 文件源码
def login(self, postData):
        status = True
        errorlist = []
        user = User.objects.filter(username = postData['username'])
        if len(postData['username']) < 1:
            errorlist.append('Must fill in Username!')
            status = False
        if len(postData['password']) < 1:
            errorlist.append('Must fill in Password!')
            status = False
        else:
            if len(user) < 1:
                errorlist.append('Username not registered!')
                status = False
        if status == False:
            return {'errors': errorlist}
        else:
            if bcrypt.hashpw(postData['password'].encode(), user[0].password.encode()) == user[0].password:
                return {'login': True}
            else:
                status = False
                errorlist.append('Password does not match username!')
                return {'errors': errorlist}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号