from app_factory.create_app import db
from models import User
from forms import RegistrationForm, LoginForm


def load_user(user_id):
    return User.query.filter_by(id=user_id).first()


def login(request):
    form = LoginForm.from_json(request.form)
    if request.method == 'POST' and form.validate():
        return True

from models import User
from forms import LoginForm


def load_user(user_id):
    """Returns a user from the database based on their id"""
    return User.query.filter_by(id=user_id).first()


def login(request):
    """Handle a login request from a user."""
    form = LoginForm.from_json(request.form)
    if request.method == 'POST' and form.validate():
        return True

Clean up unused imports and add docstrings
Clean up unused imports and add docstrings
