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


Python Core.login方法代码示例

本文整理汇总了Python中core.Core.login方法的典型用法代码示例。如果您正苦于以下问题:Python Core.login方法的具体用法?Python Core.login怎么用?Python Core.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.Core的用法示例。


在下文中一共展示了Core.login方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_authenticated

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import login [as 别名]
    def is_authenticated(self, request):
        #Check if already logged in, for use inside the application
        if Core.current_user() and Core.current_user().is_authenticated():
            return True

        #If not, then use basic auth
        else:
            auth_string = request.META.get('HTTP_AUTHORIZATION', None)

            if not auth_string:
                return False

            (authmeth, auth) = auth_string.split(" ", 1)

            if not authmeth.lower() == 'basic':
                return False

            auth = auth.strip().decode('base64')
            (username, password) = auth.split(':', 1)

            if Core.login(request, username, password):
                user = User.objects.get(username=username)
                return user.canLogin

        return False
开发者ID:frecar,项目名称:focus,代码行数:27,代码来源:authentication.py

示例2: login

# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import login [as 别名]
def login(request):
    message = ""

    redirect_to = request.REQUEST.get('next', '')

    if request.method == 'POST':

        form = LoginForm(request.POST)

        if form.is_valid():
            data = form.cleaned_data

            username = data['username']
            password = data['password']
            remember = data['remember']
            

            if Core.login(request, username, password, remember):
                user = request.user

                if user.canLogin:

                    user.use_user_language(request)

                    Log(message="%s logget inn." % user).save(user=user)

                    if not redirect_to:
                        return HttpResponseRedirect("/dashboard/")

                    return HttpResponseRedirect('%s' % redirect_to)
                
                Log(message="%s forsøkte å logge inn, men er sperret!" % user).save(user=user)
                return render_to_response('login.html')

            else:
                try:
                    user = User.objects.get(username=username)
                    Log(message="%s forsøkte å logge inn, men brukte feil passord." % user).save(user=user)
                except Exception, err:
                    Log(message="ErrorLogin: %s, username: %s" % (err, username)).save()

            Log(message="Attempt to login width username: %s, password: %s, redirect_to: %s, but failed" % (
                username, "******", redirect_to)).save()

        message = _("Wrong username or password")
开发者ID:frecar,项目名称:focus,代码行数:47,代码来源:views.py


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