예제 #1
0
파일: views.py 프로젝트: bussiere/jackpoint
def index(request):
    if request.method == "POST":  # If the form has been submitted...
        form = LoginForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            username = form.cleaned_data["Username"]
            password = form.cleaned_data["pw"]
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect("/X/")  # Redirect after POST
    else:
        form = LoginForm()  # An unbound form

    return render_to_response("index.html", {"form": form}, RequestContext(request))
예제 #2
0
파일: auth.py 프로젝트: Zerak/ShopManager
def do_login(request):
    if request.user.is_authenticated():
            return HttpResponseRedirect('/engine/dashboard')
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            user = form.get_user()
            if user.is_store:
                auth_login(request, user)
                request.session['shop'] = request.user.own_shop.id
            else:
                raise Http404
            return HttpResponseRedirect('/engine/dashboard')
    else:
        form = LoginForm()
    return render(request,
                            'engine/login.html',
                            {"form": form},
                        )
예제 #3
0
def index(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/X/')
    if request.method == 'POST': # If the form has been submitted...
        form = LoginForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            username = form.cleaned_data['Username']
            password = form.cleaned_data['PW']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect('/X/') # Redirect after POST
    else:
        form = LoginForm() # An unbound form

    return render_to_response('index.html', {
        'form': form
    },RequestContext(request))