当前位置: 首页>>代码示例>>Python>>正文


Python AuthSession.is_authenticated方法代码示例

本文整理汇总了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)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:11,代码来源:views.py

示例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)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:17,代码来源:Decorators.py

示例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)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:22,代码来源:Decorators.py

示例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()
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:5,代码来源:util.py

示例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)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:33,代码来源:views.py


注:本文中的CadVlan.Auth.AuthSession.AuthSession.is_authenticated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。