def __init__(self, username=None): """Create a User object that can be used with Flask-Login.""" self.username = username self.userID = MusicDatabase.getUserID(username) self.is_authenticated = True self.is_active = True self.is_anonymous = False
def requestNewPassword(username): if not username: username = config['username'] userID = MusicDatabase.getUserID(username) prompt = f'Enter the new password for user \'{username}\': ' password = getpass.getpass(prompt) hashed = hashpw(password.encode('utf-8'), gensalt()) if MusicDatabase.setUserPassword(userID, hashed): print('password changed successfully') else: print('Error changing password')
def __init__(self, db_row=None, owner_id=None): """Create a Playlist object.""" self.id = None self.store_songs_in_db = True self.name = None if not owner_id: username = config.config['username'] self.owner_id = MusicDatabase.getUserID(username) else: self.owner_id = owner_id self.playlist_type = DatabaseEnum('playlist_type').id_value('user') self.songs = [] if isinstance(db_row, (sqlite3.Row, RowProxy, dict)): self.id = db_row['id'] self.name = db_row['name'] self.owner_id = db_row['owner_id'] self.load_playlist_songs()