import logging
from bottle import redirect


log = logging.getLogger('bottle-auth.custom')


class Custom(object):
    def __init__(self, login_url="/login",
                 callback_url="http://127.0.0.1:8000"):
        self.login_url = login_url
        self.callback_url = callback_url

    def redirect(self, environ):
        return redirect(self.login_url)

    def get_user(self, environ):
        session = environ.get('beaker.session')
        if session.get("username", None) and session.get("apikey", None):
            return session
        return {}

import logging
from bottle import redirect


log = logging.getLogger('bottle-auth.custom')


class Custom(object):
    def __init__(self, login_url="/login",
                 callback_url="http://127.0.0.1:8000"):
        self.login_url = login_url
        self.callback_url = callback_url

    def redirect(self, environ):
        return redirect(self.login_url)

    def get_user(self, environ):
        session = environ.get('beaker.session')
        if session.get("username", None) and session.get("apikey", None):
            return session
        self.redirect(environ)

Fix Custom class, user exit in beaker.session redirect to login page
Fix Custom class, user exit in beaker.session
redirect to login page

  import logging
  from bottle import redirect
  
  
  log = logging.getLogger('bottle-auth.custom')
  
  
  class Custom(object):
      def __init__(self, login_url="/login",
                   callback_url="http://127.0.0.1:8000"):
          self.login_url = login_url
          self.callback_url = callback_url
  
      def redirect(self, environ):
          return redirect(self.login_url)
  
      def get_user(self, environ):
          session = environ.get('beaker.session')
          if session.get("username", None) and session.get("apikey", None):
              return session
-         return {}
+         self.redirect(environ)
  
Fix Custom class, user exit in beaker.session redirect to login page
## Code Before:
import logging
from bottle import redirect


log = logging.getLogger('bottle-auth.custom')


class Custom(object):
    def __init__(self, login_url="/login",
                 callback_url="http://127.0.0.1:8000"):
        self.login_url = login_url
        self.callback_url = callback_url

    def redirect(self, environ):
        return redirect(self.login_url)

    def get_user(self, environ):
        session = environ.get('beaker.session')
        if session.get("username", None) and session.get("apikey", None):
            return session
        return {}

## Instruction:
Fix Custom class, user exit in beaker.session redirect to login page
## Code After:
import logging
from bottle import redirect


log = logging.getLogger('bottle-auth.custom')


class Custom(object):
    def __init__(self, login_url="/login",
                 callback_url="http://127.0.0.1:8000"):
        self.login_url = login_url
        self.callback_url = callback_url

    def redirect(self, environ):
        return redirect(self.login_url)

    def get_user(self, environ):
        session = environ.get('beaker.session')
        if session.get("username", None) and session.get("apikey", None):
            return session
        self.redirect(environ)
