コード例 #1
0
ファイル: views.py プロジェクト: rafaellucas/ResearchProject
def loginPage(request, cookie):
    if request.POST:
        frm = loginForm(request.POST)
        frm_dict = request.POST
        user_email = frm_dict['username']
        username = get_object_or_404(User, email=user_email)
        user = authenticate(username=username, password=frm_dict['passwd'])

        if user is not None:
            if user.is_active and user.is_staff:
                login(request, user)
                return HttpResponseRedirect('/admin/')
            elif user.is_active:
                login(request, user)
                return HttpResponseRedirect('/home/%s'%user)
            else:
                return HttpResponseRedirect('/')
        else:
            return HttpResponseRedirect('/')
    else:
        frm = loginForm()

        return render("login.html", {
            "frm": frm,
        }, context_instance=RequestContext(request))
コード例 #2
0
ファイル: login.py プロジェクト: cash-allred/thepack-intex
def process_request(request):

    # if it is a post method
    if request.method == 'POST':

        #create the form instance and populate it with the data from the form
        form = loginForm(request.POST)

        if form.is_valid():
            user = authenticate(username=form.cleaned_data.get('username'),
                                password=form.cleaned_data.get('password'))
            login(request, user)
            return HttpResponseRedirect('/')

        else:
            return request.dmp.render('login.html', {
                'form': form,
            })

    # if it is a get method
    else:
        form = loginForm()

    context = {
        'form': form,
    }

    return request.dmp.render('login.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: leprecha1/ResearchProject
def loginPage(request, cookie):
    if request.POST:
        frm = loginForm(request.POST)
        frm_dict = request.POST
        user_email = frm_dict['username']
        username = get_object_or_404(User, email=user_email)
        user = authenticate(username=username, password=frm_dict['passwd'])

        if user is not None:
            if user.is_active and user.is_staff:
                login(request, user)
                return HttpResponseRedirect('/admin/')
            elif user.is_active:
                login(request, user)
                return HttpResponseRedirect('/home/%s' % user)
            else:
                return HttpResponseRedirect('/')
        else:
            return HttpResponseRedirect('/')
    else:
        frm = loginForm()

        return render("login.html", {
            "frm": frm,
        },
                      context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: rafaellucas/ResearchProject
def admin(request, cookie):
    if request.POST:
        frm = loginForm(request.POST)
        if frm.is_valid():
            frm_dict = request.POST
    else:
        frm = loginForm()

    return render("admin.html", {
        "frm": frm,
        "user": request.user,
    }, context_instance=RequestContext(request))
コード例 #5
0
ファイル: views.py プロジェクト: leprecha1/ResearchProject
def admin(request, cookie):
    if request.POST:
        frm = loginForm(request.POST)
        if frm.is_valid():
            frm_dict = request.POST
    else:
        frm = loginForm()

    return render("admin.html", {
        "frm": frm,
        "user": request.user,
    },
                  context_instance=RequestContext(request))
コード例 #6
0
def process_request(request):
    if request.method == 'POST':
        form = loginForm(request.POST)
        if form.is_valid():
            user = authenticate(username=request.POST['Username'],
                                password=request.POST['Password'])
            login(request, user)
            return HttpResponseRedirect('/', user)
        else:
            forms.ValidationError("Wrongo")
    else:
        form = loginForm()

    context = {'form': form}

    return request.dmp.render('index.html', context)
コード例 #7
0
def login(request):
    if request.method == 'POST':
        form = loginForm(request.POST)

        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']

            user = auth.authenticate(username=username, password=password)

            if user is not None:
                auth.login(request, user)
                #messages.info(request, f"You are now logged in as {username}")
                return redirect('/')
            else:
                messages.error(request, "Invalid username or password.")
                return redirect('/account/login')

    else:
        form = loginForm()
        return render(request, "login.html", {"form": form})
コード例 #8
0
ファイル: views.py プロジェクト: qiuyukuhe/yukiyam
def loginView(request,template_name):
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username,password=password)
        if user is not None:
            if user.is_active:
                login(request,user)
                return HttpResponseRedirect('/hello/')
            else:
                print "user is disable"
        else:
            print "the username or password may be wrong."
    vt = get_template(template_name)
    c = RequestContext(request,
        {
            'form':loginForm(),
            })
    return HttpResponse(vt.render(c))