code: def before_request(self) -> Optional[Response]:
          
          auth = request.authorization
          if not auth or not self._check_auth(auth.username, auth.password):
              return Response(
                  'Could not verify your access level for that URL.\n'
                  'You have to login with proper credentials', 401,
                  {'WWW-Authenticate': 'Basic realm="Login Required"'}
              )
          session['logged_in'] = auth.username
          # pylint wants this return statement
          return None
docs: Determine if a user is allowed to view this route.