Check if sessions enabled for login/logout

* Redirect to logout on session expiry to remove the session
This commit is contained in:
JonnyWong16 2016-04-27 21:26:18 -07:00
commit 85a7819469

View file

@ -61,7 +61,7 @@ def check_auth(*args, **kwargs):
if not condition(): if not condition():
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
else: else:
raise cherrypy.HTTPRedirect("auth/login") raise cherrypy.HTTPRedirect("auth/logout")
def requireAuth(*conditions): def requireAuth(*conditions):
"""A decorator that appends conditions to the auth.require config """A decorator that appends conditions to the auth.require config
@ -137,7 +137,7 @@ class AuthController(object):
@cherrypy.expose @cherrypy.expose
def login(self, username=None, password=None, remember_me='0'): def login(self, username=None, password=None, remember_me='0'):
if not plexpy.CONFIG.HTTP_PASSWORD: if not cherrypy.config.get('tools.sessions.on'):
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
if username is None or password is None: if username is None or password is None:
@ -181,7 +181,7 @@ class AuthController(object):
@cherrypy.expose @cherrypy.expose
def logout(self): def logout(self):
if not plexpy.CONFIG.HTTP_PASSWORD: if not cherrypy.config.get('tools.sessions.on'):
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT) raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
_session = cherrypy.session.get(SESSION_KEY) _session = cherrypy.session.get(SESSION_KEY)