mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 13:23:24 -07:00
Add login redirect uri
This commit is contained in:
parent
80df2b0fad
commit
80506b8541
2 changed files with 19 additions and 10 deletions
|
@ -85,7 +85,7 @@
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
statusCode: {
|
statusCode: {
|
||||||
200: function() {
|
200: function() {
|
||||||
window.location = "${http_root}";
|
window.location = "${redirect_uri or http_root}";
|
||||||
},
|
},
|
||||||
401: function() {
|
401: function() {
|
||||||
$('#incorrect-login').show();
|
$('#incorrect-login').show();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import re
|
import re
|
||||||
|
from urllib import quote, unquote
|
||||||
|
|
||||||
import cherrypy
|
import cherrypy
|
||||||
from hashing_passwords import check_hash
|
from hashing_passwords import check_hash
|
||||||
|
@ -151,7 +152,11 @@ def check_auth(*args, **kwargs):
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/logout")
|
redirect_uri = cherrypy.request.wsgi_environ['REQUEST_URI']
|
||||||
|
if redirect_uri:
|
||||||
|
redirect_uri = '?redirect_uri=' + quote(redirect_uri)
|
||||||
|
|
||||||
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/logout" + redirect_uri)
|
||||||
|
|
||||||
|
|
||||||
def requireAuth(*conditions):
|
def requireAuth(*conditions):
|
||||||
|
@ -238,22 +243,22 @@ class AuthController(object):
|
||||||
"""Called on logout"""
|
"""Called on logout"""
|
||||||
logger.debug(u"Tautulli WebAuth :: %s user '%s' logged out of Tautulli." % (user_group.capitalize(), username))
|
logger.debug(u"Tautulli WebAuth :: %s user '%s' logged out of Tautulli." % (user_group.capitalize(), username))
|
||||||
|
|
||||||
def get_loginform(self):
|
def get_loginform(self, redirect_uri=''):
|
||||||
from plexpy.webserve import serve_template
|
from plexpy.webserve import serve_template
|
||||||
return serve_template(templatename="login.html", title="Login")
|
return serve_template(templatename="login.html", title="Login", redirect_uri=unquote(redirect_uri))
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self):
|
def index(self, *args, **kwargs):
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/login")
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/login")
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def login(self):
|
def login(self, redirect_uri='', *args, **kwargs):
|
||||||
self.check_auth_enabled()
|
self.check_auth_enabled()
|
||||||
|
|
||||||
return self.get_loginform()
|
return self.get_loginform(redirect_uri=redirect_uri)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def logout(self):
|
def logout(self, redirect_uri='', *args, **kwargs):
|
||||||
self.check_auth_enabled()
|
self.check_auth_enabled()
|
||||||
|
|
||||||
payload = check_jwt_token()
|
payload = check_jwt_token()
|
||||||
|
@ -266,11 +271,15 @@ class AuthController(object):
|
||||||
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
|
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
|
||||||
|
|
||||||
cherrypy.request.login = None
|
cherrypy.request.login = None
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/login")
|
|
||||||
|
if redirect_uri:
|
||||||
|
redirect_uri = '?redirect_uri=' + redirect_uri
|
||||||
|
|
||||||
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT + "auth/login" + redirect_uri)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
def signin(self, username=None, password=None, remember_me='0', admin_login='0'):
|
def signin(self, username=None, password=None, remember_me='0', admin_login='0', *args, **kwargs):
|
||||||
if cherrypy.request.method != 'POST':
|
if cherrypy.request.method != 'POST':
|
||||||
cherrypy.response.status = 405
|
cherrypy.response.status = 405
|
||||||
return {'status': 'error', 'message': 'Sign in using POST.'}
|
return {'status': 'error', 'message': 'Sign in using POST.'}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue