old_contents: from . import auth_blueprint
  
  from flask.views import MethodView
  from flask import Blueprint, make_response, request, jsonify
  from app.models import User
  
  
  class RegistrationView(MethodView):
      """This class-based view registers a new user."""
  
      def post(self):
          # Query to see if the user already exists
          user = User.query.filter_by(email=request.data['email']).first()
  
          if not user:
              try:
                  post_data = request.data
                  # Register the user
                  email = post_data['email']
                  password = post_data['password']
                  user = User(email=email, password=password)
                  user.save()
  
                  response = {
                      'message': 'You registered successfully.',
                      'info': 'Please log in to get access.'
                  }
                  return make_response(jsonify(response)), 201
  
              except Exception as e:
                  response = {
                      'message': str(e)
                  }
                  return make_response(jsonify(response)), 401
          else:
              response = {
                  'message': 'User already exists. Please log in.'
              }
  
              return make_response(jsonify(response)), 202
  
  # Define the API resource
  registration_view = RegistrationView.as_view('registration_view')
  
  # Add the url rule for registering a user
  auth_blueprint.add_url_rule(
      '/auth/register',
      view_func=registration_view,
      methods=['POST'])
  
new_contents: from . import auth_blueprint
  
  from flask.views import MethodView
  from flask import Blueprint, make_response, request, jsonify
  from app.models import User
  
  
  class RegistrationView(MethodView):
      """This class-based view registers a new user."""
  
      def post(self):
          # Query to see if the user already exists
          user = User.query.filter_by(email=request.data['email']).first()
  
          if not user:
              try:
                  post_data = request.data
                  # Register the user
                  email = post_data['email']
                  password = post_data['password']
                  user = User(email=email, password=password)
                  user.save()
  
                  response = {
                      'message': 'You registered successfully.',
                      'info': 'Please log in to get access.'
                  }
                  return make_response(jsonify(response)), 201
  
              except Exception as e:
                  response = {
                      'message': str(e)
                  }
                  return make_response(jsonify(response)), 401
          else:
              response = {
                  'message': 'User already exists. Please log in.'
              }
  
              return make_response(jsonify(response)), 202
  
  
  class LoginView(MethodView):
      """This class-based view handles user login and access token generation."""
  
      def post(self):
          try:
              user = User.query.filter_by(email=request.data['email']).first()
  
              if user and user.password_is_valid(request.data['password']):
                  # Generate the access token
                  access_token = user.generate_token(user.id)
                  if access_token:
                      response = {
                          'message': 'You logged in successfully.',
                          'access_token': access_token.decode()
                      }
                      return make_response(jsonify(response)), 200
              else:
                  # User does not exist
                  response = {
                      'message': 'Invalid email or password, Please try again'
                  }
                  return make_response(jsonify(response)), 401
  
          except Exception as e:
              response = {
                  'message': str(e)
              }
              return make_response(jsonify(response)), 500
  
  
  # Define the API resource
  registration_view = RegistrationView.as_view('registration_view')
  login_view = LoginView.as_view('login_view')
  
  # Add the url rule for registering a user
  auth_blueprint.add_url_rule(
      '/auth/register',
      view_func=registration_view,
      methods=['POST'])
  auth_blueprint.add_url_rule(
      '/auth/login',
      view_func=login_view,
      methods=['POST']
  )
  
subject: add login functionality, define url for login