示例#1
0
 def login(cls, username, password):
     user = cls.get_by_name(username)
     if user:
         salt = user.salt
         correct_hash = user.pw_hash
         new_hash = hashpw(password, salt)[0]
         if correct_hash == new_hash:
             return user
示例#2
0
 def register(cls, username, password, email = None):
     pw_hash, salt = hashpw(password)
     return User(username = username,
                 pw_hash = pw_hash,
                 salt = salt,
                 email = email)