flask login attemted_user cant see check_password_correction method

from flask import Flask, render_template, request, redirect, url_for, flash
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key'
login_manager = LoginManager(app)
login_manager.login_view = 'login'

# Mock user class for demonstration purposes
class User(UserMixin):
    def __init__(self, user_id, username, password):
        self.id = user_id
        self.username = username
        self.password = generate_password_hash(password, method='sha256')

# Mock user database for demonstration purposes
users_db = {
    1: User(1, 'user1', 'password1'),
    2: User(2, 'user2', 'password2')

def load_user(user_id):
    return users_db.get(int(user_id))

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        attempted_user = next((user for user in users_db.values() if user.username == username), None)

        if attempted_user and check_password_hash(attempted_user.password, password):
            flash('Login successful', 'success')
            return redirect(url_for('dashboard'))
            flash('Login failed. Check your username and password.', 'danger')

    return render_template('login.html')

def dashboard():
    return f'Hello, {current_user.username}! Welcome to the dashboard.'

def logout():
    return redirect(url_for('login'))

if __name__ == '__main__':