我正在尝试登录用户。创建他的个人资料后。但是当他授权他时,他以匿名用户身份登录。
from django.contrib.auth import authenticate as authorise
def shopify_register(request):
print "############*****GOT DETAILS*****############"
password = request.POST['pass']
subs, stat = Subscription.objects.get_or_create(validity=datetime.now()+timedelta(days=30))
newuser, stat = User.objects.get_or_create(username=request.POST['email'])
newuser.set_password(password)
newuser.save()
user, stat = UserProfile.objects.get_or_create(subscription=subs,user=newuser)
domain, stat = Domain.objects.get_or_create(user_profile=user, shortname=request.POST['shop_name'], keywords=request.POST['keywords'])
profile,stat = ShopifyUserProfile.objects.get_or_create(shop_user =user.. etc )
username = request.POST['email']
authuser = authorise(username=username, password=mdpass)
domain = Domain.objects.get(user_profile=user)
testimonies = Testimony.objects.filter(domain=domain).filter(show=0).order_by('-timestamp')
c = RequestContext(request, {
'user' : user,
'testimonies': testimonies,
'request': request,
'mentions': 1,
'domain': domain
})
return render_to_response('homepage.html', context_instance=c)
更新 :
authuser = authorise(username=username, password=mdpass)
这不授权用户。虽然用户已经创建。
它工作正常,但它将用户记录为匿名用户?这里有什么问题?
删除了 md5 散列,但仍然没有授权用户。
更新:2
ipdb> authuser = authorise(username=username, password=password)
ipdb> authuser
<User: ratan@kumar.com>
ipdb> temp=auth_login(request,authuser)
ipdb> temp
ipdb> print temp
None
这意味着它已授权用户,但无法登录。