Files
modoboa/auth/views.py
T
Antoine Nguyen 6c7a64e947 !! VERY UNSTABLE CHANGESET !!
Many updates in this commit:
 * first work on the webmail plugin, for now only emails listing and folders browsing is supported...
 * New login form,
 * New graphical layout (still needing improvments)
 * code factoring between webmail and quarantine plugins
 * etc.
2010-01-15 12:15:15 +01:00

33 lines
1.3 KiB
Python
Executable File

# -*- coding: utf-8 -*-
from django.contrib.auth import authenticate, login
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
import mailng.admin
from forms import LoginForm
def dologin(request):
error = None
if request.method == "POST":
form = LoginForm(request.POST)
user = authenticate(username=request.POST["username"],
password=request.POST["password"])
if user:
if user.is_active:
login(request, user)
request.session["password"] = request.POST["password"]
next = request.POST["next"]
if next == "None":
next = reverse(mailng.admin.views.domains)
return HttpResponseRedirect(next)
else:
error = _("Account is disabled.")
error = _("Your username and password didn't match. Please try again.")
else:
form = LoginForm()
next = request.GET.has_key("next") and request.GET["next"] or None
return render_to_response("registration/login.html", {
"form" : form, "error" : error, "next" : next
})