views.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:iam-idbase 作者: UWIT-IAM 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号