render_to auth_facebook login html validate_facebook_co okies def logi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@render_to('auth_facebook/login.html')
@validate_facebook_cookies()
def login(request):
output = {'API_KEY': settings.FACEBOOK_API_KEY}
facebook_id = int(request.COOKIES.get('%s_user' % settings.FACEBOOK_API_KEY))
try:
fb = FacebookProfile.objects.get(facebook_id = facebook_id)
except FacebookProfile.DoesNotExist:
facebook_profile = FacebookProfile(profile=request.user,
facebook_id = facebook_id)
facebook_profile.save()
user = auth.authenticate(facebook_id=facebook_id)
login_and_set_language(request, user)
return HttpResponseRedirect(reverse('my-profile'))