예제 #1
0
파일: views.py 프로젝트: peterzakin/humbert
def home(request):
    c = RequestContext(request)
    if request.user.is_authenticated():
        Profile.init_session(request)
        c['bio'] = request.session['bio']
        return render_to_response('logged_in_home.html', c)

    return render_to_response('landing.html', c)
예제 #2
0
파일: views.py 프로젝트: peterzakin/humbert
def fb_login_with_token_and_id(request):
    #check to see if we have a user with this fb_id
    fb_id = request.POST.get('fb_id')
    access_token = request.POST.get('access_token')
    user_set = Profile.objects.filter(fb_id=fb_id)

    # could probably change this to access token; i.e lookup by access token and not id
    if len(user_set) == 0:
        # create new user
        user = Profile.create_new_fb_user(fb_id, access_token)
        if user is not None:
            #if we created the user alright lets log him in 
            user.backend = 'django.contrib.auth.backends.ModelBackend'    
            login(request,user)
            
    else:
        user = user_set[0]
        #update the access token
        user.extend_token(access_token)
        user.backend = 'django.contrib.auth.backends.ModelBackend'    
        login(request,user)

    print user.__dict__
    return HttpResponse('Hey client side, we just logged u in. -serverside out')