示例#1
0
def generate_new_api_key(user):
    new_api_key = secure_random_string_generator(32)
    new_api_key_hash = get_hash_for_api_key(new_api_key)
    user.api_key = new_api_key_hash.encode("utf8")
    db.session.add(user)
    db.session.commit()
    return new_api_key
示例#2
0
 def __init__(self, login="******", password="", roles=None):
     if roles is None:
         roles = []
     self.login = login
     self.display_name = login
     if password == "":
         password = secure_random_string_generator(32)
     self.password = pwd_context.encrypt(password)
     self.is_active = True
     self.roles = roles
     self.api_key = ""