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}
评论列表
文章目录