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

- from app_factory.create_app import db
  from models import User
- from forms import RegistrationForm, LoginForm
+ 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
## Code Before:
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

## Instruction:
Clean up unused imports and add docstrings
## Code After:
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
