def logout(request):
"""
Logout a user by removing all cookies that don't have the magic string
'persistent', and redirect to settings.LOGOUT_REDIRECT.
"""
next_param = request.GET.get('next', None)
next_url = (next_param
if next_param and is_safe_url(next_param)
else getattr(settings, 'LOGOUT_REDIRECT', None))
response = (redirect(next_url)
if next_url
else render(request, 'idbase/logout.html'))
logger.debug('Logging out {}@washington.edu and redirecting to {}'.format(
request.uwnetid, next_url))
# delete all cookies that don't contain the string 'persistent'
delete_keys = [key for key in request.COOKIES
if not re.search(r'persistent', key, re.IGNORECASE)]
for key in delete_keys:
response.delete_cookie(key)
return response
评论列表
文章目录