Exemple #1
0
 def test_form_login(self):
     request = self.factory.post('', {
         'username': '******',
         'password': '******'
     })
     form = LoginForm(request.POST)
     self.assertTrue(form.is_valid())
     user = form.login(request)
     self.assertTrue(user, self.user)
Exemple #2
0
def login_user(request):
    form = LoginForm(request.POST or None)
    if request.method == "POST":
        if form.is_valid():
            user = form.login(request)
            if user:
                login(request, user)
                if request.POST.get("next"):
                    return HttpResponseRedirect(request.POST.get("next"))
                else:
                    return HttpResponseRedirect("/")

    return render(request, "core/login.html", {"form": form})
Exemple #3
0
def login_user(request):
    form = LoginForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            user = form.login(request)
            if user:
                login(request, user)
                if request.POST.get('next'):
                    return HttpResponseRedirect(request.POST.get('next'))
                else:
                    return HttpResponseRedirect('/')

    return render(request, 'core/login.html', {'form': form})
Exemple #4
0
def login_user(request):
    form = LoginForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            user = form.login(request)
            if user:
                login(request, user)
                if request.GET.get('next'):
                    # Redirect to a success page.
                    return HttpResponseRedirect(request.GET.get('next'))
                else:
                    return HttpResponseRedirect('/')

    return render(request, 'core/login.html', {'form': form})
Exemple #5
0
 def test_form_login(self):
     request = self.factory.post('', {'username': '******', 'password': '******'})
     form = LoginForm(request.POST)
     self.assertTrue(form.is_valid())
     user = form.login(request)
     self.assertTrue(user, self.user)