Fixed login url

This commit is contained in:
Adolfo Gómez García 2019-12-26 12:52:51 +01:00
parent ddc2699774
commit a4353dde86
4 changed files with 10 additions and 4 deletions

View File

@ -135,13 +135,13 @@ class GlobalRequestMiddleware:
request.ip = request.META['REMOTE_ADDR']
except Exception:
logger.exception('Request ip not found!!')
request.ip = '0.0.0.0' # No remote addr?? set this IP to a "basic" one, anyway, this should never ocur
request.ip = '' # No remote addr?? ...
try:
proxies = request.META['HTTP_X_FORWARDED_FOR'].split(",")
request.ip_proxy = proxies[0]
if request.ip is None or behind_proxy is True: # Request.IP will be None in case of nginx & gunicorn
if not request.ip or behind_proxy is True: # Request.IP will be None in case of nginx & gunicorn
request.ip = request.ip_proxy # Stores the ip
# will raise "list out of range", leaving ip_proxy = proxy in case of no other proxy apart of nginx
request.ip_proxy = proxies[1]

View File

@ -64,12 +64,12 @@ urlpatterns = [
# Login/logout
path(r'uds/page/login/', uds.web.views.modern.login, name='page.login'),
re_path(r'^uds/page/login/(?P<tag>[a-zA-Z0-9-])$', uds.web.views.modern.login, name='page.login.tag'),
re_path(r'^uds/page/login/(?P<tag>[a-zA-Z0-9-]+)$', uds.web.views.modern.login, name='page.login.tag'),
path(r'uds/page/logout/', uds.web.views.modern.logout, name='page.logout'),
# Error URL (just a placeholder, calls index with data on url for angular)
re_path(r'^uds/page/error/(?P<error>[a-zA-Z0-9=-]+)$', uds.web.views.error, name='page.error'),
re_path(r'^uds/page/error/(?P<err>[a-zA-Z0-9=-]+)$', uds.web.views.error, name='page.error'),
# Download plugins URL (just a placeholder, calls index with data on url for angular)
path(r'uds/page/client-download', uds.web.views.modern.index, name='page.client-download'),

View File

@ -72,6 +72,8 @@ def udsJs(request: 'HttpRequest') -> str:
if csrf_token is not None:
csrf_token = str(csrf_token)
tag = request.session.get('tag', None)
if GlobalConfig.DISALLOW_GLOBAL_LOGIN.getBool(False) is True:
try:
authenticators = [Authenticator.objects.get(small_name=auth_host)]
@ -83,6 +85,9 @@ def udsJs(request: 'HttpRequest') -> str:
else:
authenticators = Authenticator.objects.all().exclude(visible=False)
if tag:
authenticators = [x for x in authenticators if x.small_name == tag]
# the auths for client
def getAuthInfo(auth: Authenticator):
theType = auth.getType()

View File

@ -76,6 +76,7 @@ def login(request: HttpRequest, tag: typing.Optional[str] = None) -> HttpRespons
request.session['errors'] = [data]
return index(request)
else:
request.session['tag'] = tag
response = index(request)
return response