本文整理匯總了Python中django.conf.settings.LOGOUT_REDIRECT_URL屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.LOGOUT_REDIRECT_URL屬性的具體用法?Python settings.LOGOUT_REDIRECT_URL怎麽用?Python settings.LOGOUT_REDIRECT_URL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.conf.settings
的用法示例。
在下文中一共展示了settings.LOGOUT_REDIRECT_URL屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_next_page
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def get_next_page(self):
if self.next_page is not None:
next_page = resolve_url(self.next_page)
elif settings.LOGOUT_REDIRECT_URL:
next_page = resolve_url(settings.LOGOUT_REDIRECT_URL)
else:
next_page = self.next_page
if (self.redirect_field_name in self.request.POST or
self.redirect_field_name in self.request.GET):
next_page = self.request.POST.get(
self.redirect_field_name,
self.request.GET.get(self.redirect_field_name)
)
url_is_safe = is_safe_url(
url=next_page,
allowed_hosts=self.get_success_url_allowed_hosts(),
require_https=self.request.is_secure(),
)
# Security check -- Ensure the user-originating redirection URL is
# safe.
if not url_is_safe:
next_page = self.request.path
return next_page
示例2: get_redirect_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def get_redirect_url(self, *args, **kwargs):
if hasattr(self.request.user, 'oidc_profile'):
self.request.realm.client.openid_api_client.logout(
self.request.user.oidc_profile.refresh_token
)
self.request.user.oidc_profile.access_token = None
self.request.user.oidc_profile.expires_before = None
self.request.user.oidc_profile.refresh_token = None
self.request.user.oidc_profile.refresh_expires_before = None
self.request.user.oidc_profile.save(update_fields=[
'access_token',
'expires_before',
'refresh_token',
'refresh_expires_before'
])
logout(self.request)
if settings.LOGOUT_REDIRECT_URL:
return resolve_url(settings.LOGOUT_REDIRECT_URL)
return reverse('keycloak_login')
示例3: post
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def post(self, request):
""" Processes POST requests. """
logout_url = settings.LOGOUT_REDIRECT_URL or '/'
# Log out the current user.
if request.user.is_authenticated:
try:
logout_url = self.provider_end_session_url \
if oidc_rp_settings.PROVIDER_END_SESSION_ENDPOINT else logout_url
except KeyError: # pragma: no cover
logout_url = logout_url
auth.logout(request)
# Redirects the user to the appropriate URL.
return HttpResponseRedirect(logout_url)
示例4: provider_end_session_url
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def provider_end_session_url(self):
""" Returns the end-session URL. """
q = QueryDict(mutable=True)
q[oidc_rp_settings.PROVIDER_END_SESSION_REDIRECT_URI_PARAMETER] = \
self.request.build_absolute_uri(settings.LOGOUT_REDIRECT_URL or '/')
q[oidc_rp_settings.PROVIDER_END_SESSION_ID_TOKEN_PARAMETER] = \
self.request.session['oidc_auth_id_token']
return '{}?{}'.format(oidc_rp_settings.PROVIDER_END_SESSION_ENDPOINT, q.urlencode())
示例5: logout
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def logout(request):
if request.method=="POST":
do_logout(request)
redirect_url = settings.LOGOUT_REDIRECT_URL or '/'
return HttpResponseRedirect(redirect_url)
else:
return render(request, 'accounts/logout.html')
示例6: oauth2_logout
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def oauth2_logout(request):
logout(request)
return redirect(settings.LOGOUT_REDIRECT_URL)
示例7: logout
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import LOGOUT_REDIRECT_URL [as 別名]
def logout(request, next_page=None,
template_name='registration/logged_out.html',
redirect_field_name=REDIRECT_FIELD_NAME,
extra_context=None):
"""
Logs out the user and displays 'You are logged out' message.
"""
auth_logout(request)
if next_page is not None:
next_page = resolve_url(next_page)
elif settings.LOGOUT_REDIRECT_URL:
next_page = resolve_url(settings.LOGOUT_REDIRECT_URL)
if (redirect_field_name in request.POST or
redirect_field_name in request.GET):
next_page = request.POST.get(redirect_field_name,
request.GET.get(redirect_field_name))
# # Security check -- don't allow redirection to a different host.
# if not is_safe_url(url=next_page, host=request.get_host()):
# next_page = request.path
if next_page:
# Redirect to this page until the session has been cleared.
return HttpResponseRedirect(next_page)
current_site = get_current_site(request)
context = {
'site': current_site,
'site_name': current_site.name,
'title': _('Logged out')
}
if extra_context is not None:
context.update(extra_context)
return TemplateResponse(request, template_name, context)