605 |
605 |
"""
|
606 |
606 |
next_url = next_url or utils_misc.select_next_url(request, settings.LOGIN_REDIRECT_URL)
|
607 |
607 |
|
608 |
|
ctx = {}
|
609 |
|
ctx['next_url'] = next_url
|
610 |
|
ctx['redir_timeout'] = 60
|
611 |
|
local_logout_done = False
|
612 |
|
|
613 |
608 |
if request.user.is_authenticated:
|
614 |
609 |
if check_referer and not utils_misc.check_referer(request):
|
615 |
|
return render(request, 'authentic2/logout_confirm.html', ctx)
|
|
610 |
return render(request, 'authentic2/logout_confirm.html', {'next_url': next_url})
|
|
611 |
fragments = logout_list(request)
|
616 |
612 |
do_local = do_local and 'local' in request.GET
|
617 |
|
if not do_local:
|
618 |
|
fragments = logout_list(request)
|
619 |
|
if fragments:
|
620 |
|
# Full logout with iframes
|
621 |
|
next_url = utils_misc.make_url(
|
622 |
|
'auth_logout', params={'local': 'ok'}, next_url=next_url, sign_next_url=True
|
623 |
|
)
|
624 |
|
ctx['next_url'] = next_url
|
625 |
|
ctx['logout_list'] = fragments
|
626 |
|
ctx['message'] = _('Logging out from all your services')
|
627 |
|
return render(request, 'authentic2/logout.html', ctx)
|
|
613 |
if not do_local and fragments:
|
|
614 |
# Full logout with iframes
|
|
615 |
local_logout_next_url = utils_misc.make_url(
|
|
616 |
'auth_logout', params={'local': 'ok'}, next_url=next_url, sign_next_url=True
|
|
617 |
)
|
|
618 |
ctx = {}
|
|
619 |
ctx['next_url'] = local_logout_next_url
|
|
620 |
ctx['redir_timeout'] = 60
|
|
621 |
ctx['logout_list'] = fragments
|
|
622 |
ctx['message'] = _('Logging out from all your services')
|
|
623 |
return render(request, 'authentic2/logout.html', ctx)
|
628 |
624 |
# Get redirection targets for full logout with redirections
|
629 |
625 |
# (needed before local logout)
|
630 |
626 |
targets = redirect_logout_list(request)
|
631 |
|
logger.debug('Accumulated redirections : %s', targets)
|
|
627 |
targets.append(next_url)
|
632 |
628 |
# Local logout
|
633 |
629 |
request.journal.record('user.logout')
|
634 |
630 |
auth_logout(request)
|
635 |
|
logger.info('Logged out')
|
636 |
|
local_logout_done = True
|
637 |
631 |
# Last redirection will be the current next_url
|
638 |
|
targets.append(next_url)
|
639 |
632 |
# Put redirection targets in session (after local logout)
|
640 |
633 |
request.session['logout_redirections'] = targets
|
641 |
|
logger.debug('All planned redirections : %s', targets)
|
642 |
|
# Full logout by redirections if any
|
643 |
|
targets = request.session.pop('logout_redirections', None)
|
644 |
|
if targets:
|
645 |
|
# Full logout with redirections
|
646 |
|
logger.debug('Redirections queue: %s', targets)
|
647 |
|
next_url = targets.pop(0)
|
648 |
|
request.session['logout_redirections'] = targets
|
649 |
|
logger.debug('Next redirection : %s', next_url)
|
650 |
|
response = shortcuts.redirect(next_url)
|
651 |
|
if local_logout_done:
|
|
634 |
targets = request.session.pop('logout_redirections', None)
|
|
635 |
if targets:
|
|
636 |
# Full logout with redirections
|
|
637 |
next_url = targets.pop(0)
|
|
638 |
request.session['logout_redirections'] = targets
|
|
639 |
response = shortcuts.redirect(next_url)
|
652 |
640 |
response.set_cookie('a2_just_logged_out', 1, max_age=60, samesite='Lax')
|
653 |
|
return response
|
|
641 |
return response
|
|
642 |
else:
|
|
643 |
# continue redirections after logout
|
|
644 |
targets = request.session.pop('logout_redirections', None)
|
|
645 |
if targets:
|
|
646 |
# Full logout with redirections
|
|
647 |
next_url = targets.pop(0)
|
|
648 |
request.session['logout_redirections'] = targets
|
|
649 |
return shortcuts.redirect(next_url)
|
654 |
650 |
|
655 |
651 |
|
656 |
652 |
def login_password_login(request, authenticator, *args, **kwargs):
|
657 |
|
-
|