I am trying to login a user . after creating his profile . but when he authorises him he logs in as anonymous user.
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)
UPDATE :
authuser = authorise(username=username, password=mdpass)
this does not authorises the user . though the User has been created .
It works fine but it logs user as anonymous user ? what is wrong here ?
Removed the md5 hashing but still user is not being authorised.
UPDATE :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
It means it has authorised the user but it has not able to log him in.