本文整理汇总了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
示例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")