Merge remote-tracking branch 'origin/v3.0'

This commit is contained in:
Adolfo Gómez García 2020-11-26 11:52:21 +01:00
commit e9a4da5acc
3 changed files with 20 additions and 14 deletions

View File

@ -397,6 +397,11 @@ def webLogout(
Helper function to clear user related data from session. If this method is not used, the session we be cleaned anyway
by django in regular basis.
"""
if exit_url is None:
exit_url = request.build_absolute_uri(reverse('page.logout'))
# exit_url = GlobalConfig.LOGIN_URL.get()
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
# exit_url = exit_url.replace('http://', 'https://')
if request.user:
authenticator = request.user.manager.getInstance()
@ -413,14 +418,10 @@ def webLogout(
else: # No user, redirect to /
return HttpResponseRedirect(reverse('page.login'))
request.session.flush()
if exit_url is None:
exit_url = reverse('page.logout')
# exit_url = GlobalConfig.LOGIN_URL.get()
# if GlobalConfig.REDIRECT_TO_HTTPS.getBool() is True:
# exit_url = exit_url.replace('http://', 'https://')
# Try to delete session
request.session.flush()
response = HttpResponseRedirect(request.build_absolute_uri(exit_url))
if authenticator:
authenticator.webLogoutHook(username, request, response)

View File

@ -883,9 +883,13 @@ class UserInterface(metaclass=UserInterfaceType):
_gui: typing.Dict[str, gui.InputField]
def __init__(self, values: gui.ValuesType = None) -> None:
# : If there is an array of elements to initialize, simply try to store values on form fields
# Generate a deep copy of inherited Gui, so each User Interface instance has its own "field" set, and do not share the "fielset" with others, what can be really dangerous
# Till now, nothing bad happened cause there where being used "serialized", but this do not have to be this way
# : If there is an array of elements to initialize, simply try to store
# values on form fields.
# Generate a deep copy of inherited Gui, so each User Interface instance
# has its own "field" set, and do not share the "fielset" with others, what
# can be really dangerous. Till now, nothing bad happened cause there where
# being used "serialized", but this do not have to be this way
self._gui = copy.deepcopy(
self._gui
) # Ensure "gui" is our own instance, deep copied from base
@ -1065,7 +1069,7 @@ class UserInterface(metaclass=UserInterfaceType):
represent it at user interface and manage it.
Args:
object: If not none, object that will get its "initGui" invoked
obj: If any, object that will get its "initGui" invoked
This will only happen (not to be None) in Services.
"""
logger.debug('Active language for theGui translation: %s', get_language())
@ -1075,7 +1079,7 @@ class UserInterface(metaclass=UserInterfaceType):
theGui = obj
res: typing.List[typing.MutableMapping[str, typing.Any]] = []
# pylint: disable=protected-access,maybe-no-member
for key, val in theGui._gui.items():
logger.debug('%s ### %s', key, val)
res.append({'name': key, 'gui': val.guiDescription(), 'value': ''})

View File

@ -72,6 +72,7 @@ def authCallback(request: HttpRequest, authName: str) -> HttpResponse:
authenticator = Authenticator.objects.get(name=authName)
params = request.GET.copy()
params.update(request.POST)
params['_query'] = request.META.get('QUERY_STRING', '')
logger.debug('Auth callback for %s with params %s', authenticator, params.keys())
@ -110,9 +111,9 @@ def authCallback_stage2(request: HttpRequest, ticketId: str) -> HttpResponse:
return response
except auths.exceptions.Redirect as e:
return HttpResponseRedirect(request.build_absolute_uri(str(e)))
return HttpResponseRedirect(request.build_absolute_uri(str(e)) if e.args and e.args[0] else '/' )
except auths.exceptions.Logout as e:
return webLogout(request, request.build_absolute_uri(str(e)))
return webLogout(request, request.build_absolute_uri(str(e)) if e.args and e.args[0] else None)
except Exception as e:
logger.exception('authCallback')
return errors.exceptionView(request, e)