LU06.L08 - Passwort-Hashing in der Todo-Liste

userDao.py
    def add_user(self, user):
        hashed_pw = bcrypt.hashpw(user.password.encode('utf-8'), bcrypt.gensalt())
        self.cursor.execute("INSERT INTO users (username, email, password) VALUES (?, ?, ?)",
                            (user.username, user.email, hashed_pw))
        self.conn.commit()
userBlueprint.py
def login():
    data = request.get_json()
    user = user_dao.get_user_by_username(data['username'])
    print(user.password)
    if user and bcrypt.checkpw(data['password'].encode('utf-8'), user.password):
        login_user(user)
        return jsonify({'success': True}), 200
    return jsonify({'error': 'Invalid username or password'}), 401
requirements.txt
bcrypt==4.0.1