예제 #1
0
def index(request, loginFail=0):
    if 'logged_in' in request.session:
        return redirect('/chefeditor/explore/0')
    else:
        if request.method == 'POST':
            form = RegistrationForm(request.POST)
            if form.is_valid():
                l = form.save()
                user = Users(login=l,
                             name=request.POST.get('name'),
                             profile_pic='avatar.jpg')
                saved_user = user.save()
                login = Login.objects.filter(email=request.POST.get('email'))
                print login
                set_session(request, login)
                return redirect('/chefeditor/explore/0')
        else:
            form = RegistrationForm()

        context = {'form': form}
        if loginFail == '1':
            context['loginFail'] = 1
            context['errorMessage'] = "Incorrect Email ID and Password"
        else:
            context['loginFail'] = 0
        return render(request, 'home.html', context)
예제 #2
0
파일: views.py 프로젝트: Murdocc007/mysite
def checkFBLogin(request):
    if request.method == 'POST':
        femail = request.POST.get('email')
        fname = request.POST.get('name')
        fid = request.POST.get('id')
        login = Login.objects.filter(email=femail)
        if login:
            set_session(request, login)
        else:
            login_object = Login(email = femail, password = None)
            login_object.save()
            profile_pic_str = 'http://graph.facebook.com/' + fid + '/picture?type=large'
            user_object = Users(login = login_object, name = fname, profile_pic = profile_pic_str)
            user_object.save()
            set_session_obj(request, login_object)

        return HttpResponse("logged_in")
    else:
         return HttpResponse("not_logged_in")
예제 #3
0
def checkFBLogin(request):
    if request.method == 'POST':
        femail = request.POST.get('email')
        fname = request.POST.get('name')
        fid = request.POST.get('id')
        login = Login.objects.filter(email=femail)
        if login:
            set_session(request, login)
        else:
            login_object = Login(email=femail, password=None)
            login_object.save()
            profile_pic_str = 'http://graph.facebook.com/' + fid + '/picture?type=large'
            user_object = Users(login=login_object,
                                name=fname,
                                profile_pic=profile_pic_str)
            user_object.save()
            set_session_obj(request, login_object)

        return HttpResponse("logged_in")
    else:
        return HttpResponse("not_logged_in")
예제 #4
0
파일: views.py 프로젝트: Murdocc007/mysite
def index(request, loginFail = 0):
    
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid() :
                l = form.save()
                user = Users(login = l, name = request.POST.get('name'), profile_pic = 'avatar.jpg')
                saved_user = user.save()
                login = Login.objects.filter(email = request.POST.get('email'))
                print login
                set_session(request, login)
                return redirect('/chefeditor/explore/0')
    else:
        form = RegistrationForm()

    context = {'form' : form }
    if loginFail == '1':
        context['loginFail'] = 1
        context['errorMessage']="Incorrect Email ID and Password"
    else:
        context['loginFail'] = 0
    return render(request, 'home.html', context)