def val_Login(self, postData):
user = User.objects.filter(email=postData['email'])
status = True
errorlist = []
if len(postData['email']) < 1 or len(postData['password']) < 1 :
errorlist.append("Please enter valid email and password")
return {'errors': errorlist}
if not EMAIL_REGEX.match(postData['email']):
errorlist.append("Not a valid email")
return {'errors': errorlist}
if len(user) < 1:
errorlist.append("You need to register first")
status = False
if status == False:
return {'errors': errorlist}
else:
if bcrypt.hashpw(postData['password'].encode(), user[0].password.encode()) == user[0].password:
return {'register': user[0]}
else:
errorlist.append("Incorrect Password")
return {'errors': errorlist}
评论列表
文章目录