本文整理汇总了Python中CadVlan.Auth.AuthSession.AuthSession.is_authenticated方法的典型用法代码示例。如果您正苦于以下问题:Python AuthSession.is_authenticated方法的具体用法?Python AuthSession.is_authenticated怎么用?Python AuthSession.is_authenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CadVlan.Auth.AuthSession.AuthSession
的用法示例。
在下文中一共展示了AuthSession.is_authenticated方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handler500
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import is_authenticated [as 别名]
def handler500(request):
auth = AuthSession(request.session)
messages.add_message(request, messages.ERROR, auth_messages.get("500"))
if auth.is_authenticated():
return HttpResponseRedirect(URL_HOME)
return HttpResponseRedirect(URL_LOGIN)
示例2: _decorated
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import is_authenticated [as 别名]
def _decorated(request, *args, **kwargs):
auth = AuthSession(request.session)
if auth.is_authenticated():
return view_func(request, *args, **kwargs)
else:
if request.is_ajax():
response = HttpResponseRedirect(URL_LOGIN)
response.status_code = 278
response.content = error_messages.get('login_required')
return response
else:
return HttpResponseRedirect(URL_LOGIN + '?redirect=' + request.path)
示例3: _has_perm
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import is_authenticated [as 别名]
def _has_perm(request, *args, **kwargs):
auth = AuthSession(request.session)
if auth.is_authenticated():
user = auth.get_user()
for perm in permission:
write = perm.get("write")
read = perm.get("read")
if not user.has_perm(perm['permission'], write, read):
messages.add_message(
request, messages.ERROR, auth_messages.get('user_not_authorized'))
return HttpResponseRedirect(URL_HOME)
return view_func(request, *args, **kwargs)
else:
return HttpResponseRedirect(URL_LOGIN)
示例4: is_authenticated
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import is_authenticated [as 别名]
def is_authenticated(request):
auth = AuthSession(request.session)
return auth.is_authenticated()
示例5: render_to_response
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import is_authenticated [as 别名]
except Exception, e:
logger.error(e)
user = {}
messages.add_message(
request, messages.ERROR, auth_messages.get("500"))
return render_to_response(templates.LOGIN, {'form': form, 'form_pass': form_pass, 'modal': modal_auto_open}, context_instance=RequestContext(request))
else:
return render_to_response(templates.LOGIN, {'form': form, 'form_pass': form_pass, 'modal': modal_auto_open}, context_instance=RequestContext(request))
else:
auth = AuthSession(request.session)
if auth.is_authenticated():
return HttpResponseRedirect(URL_HOME)
form = LoginForm()
form_pass = PassForm()
if request.GET is not None:
form.fields['redirect'].initial = request.GET.get('redirect')
return render_to_response(templates.LOGIN, {'form': form, 'form_pass': form_pass, 'modal': modal_auto_open}, context_instance=RequestContext(request))
@log
def logout(request):
auth = AuthSession(request.session)
auth.logout()
return HttpResponseRedirect(URL_LOGIN)