Example #1
0
def authenticate(username, password):
    '''
    进行身份验证
    :param username: 用户名
    :param password: 密码
    :return: 返回身份是否正确
    '''
    if username and password:
        if User.get_password(username) and hash_it(
                password) == User.get_password(username):  #
            return True
    return False
Example #2
0
 def authenticate(self, password):
     """
     用户名和密码验证
     :param password:  密码
     :return: True 或者 False  True代表验证通过,False代表验证没过
     """
     hash_password = hashed(password)
     if hash_password == User.get_password(username=self.username,
                                           session=self.db):
         return True
     else:
         return False
Example #3
0
def authenticate(username, password):
    """
    校验用户名和密码是否符合记录.
    :param username:
    :param password:
    :return: True 代表验证通过, False 代表验证失败.
    """
    print(username, password)
    if username and password:
        # return username == username and hashed(password) == hashed(password)
        hashed_password = User.get_password(username)
        return hashed(password) == hashed_password  #验证表单和数据库是否一样.
    else:
        return False
Example #4
0
def authenticate(username, password):
    if hashMD5(password) == User.get_password(username):
        return True
    else:
        return False