本文整理汇总了Python中django.contrib.auth.views.LogoutView方法的典型用法代码示例。如果您正苦于以下问题:Python views.LogoutView方法的具体用法?Python views.LogoutView怎么用?Python views.LogoutView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.views
的用法示例。
在下文中一共展示了views.LogoutView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_view
# 需要导入模块: from django.contrib.auth import views [as 别名]
# 或者: from django.contrib.auth.views import LogoutView [as 别名]
def process_view(self, request, view_func, view_args, view_kwargs):
"""Forwards unauthenticated requests to the admin page to the CAS
login URL, as well as calls to django.contrib.auth.views.login and
logout.
"""
if view_func == login:
return cas_login(request, *view_args, **view_kwargs)
if view_func == logout:
return cas_logout(request, *view_args, **view_kwargs)
if view_func in (cas_login, cas_logout):
return None
if settings.CAS_ADMIN_PREFIX:
if not request.path.startswith(settings.CAS_ADMIN_PREFIX):
return None
elif not view_func.__module__.startswith('django.contrib.admin.'):
return None
if view_func.__name__ == 'logout':
return HttpResponseRedirect(reverse(settings.CAS_LOGOUT_URL_NAME))
if request.user.is_authenticated:
if request.user.is_staff:
return None
raise PermissionDenied(_('You do not have staff privileges.'))
params = urllib_parse.urlencode({REDIRECT_FIELD_NAME: request.get_full_path()})
return HttpResponseRedirect(reverse(settings.CAS_LOGIN_URL_NAME) + '?' + params)