def register(request): if request.method == "POST": form = UserCreationForm(request.POST) if form.is_valid(): new_user = form.save() new_user = authenticate(email=request.POST["email"], password=request.POST["password1"]) login(request, new_user) user_login.delay(str(request.POST["email"])) return HttpResponseRedirect("/tasks/") else: form = UserCreationForm() return render(request, "registration/register.html", {"form": form})
def auth_login(request): if request.method == "POST": email = request.POST["email"] password = request.POST["password"] user = authenticate(email=email, password=password) if user is not None: login(request, user) user_login.delay(email) return HttpResponseRedirect("/tasks/") else: return HttpResponse("Invalid login.") else: form = UserCreationForm() return render(request, "registration/login.html", {"form": form})