app/projrev/views/login.py
changeset 8 294ff7ac9cb6
parent 1 324233b04d76
child 9 38727da8a948
--- a/app/projrev/views/login.py	Thu Aug 06 18:49:06 2009 +0530
+++ b/app/projrev/views/login.py	Thu Aug 06 20:20:36 2009 +0530
@@ -9,8 +9,10 @@
 
 from django.contrib.auth import authenticate
 from django.contrib.auth import login
+from django.contrib.auth import logout
 from django.contrib.auth.forms import AuthenticationForm
 from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
 from django.db import IntegrityError
 from django.http import HttpResponseRedirect
 from django.shortcuts import render_to_response
@@ -21,6 +23,9 @@
   """Validate the user and log him in.
   """
 
+  template = 'projrev/auth/login.html'
+  context = {}
+
   if request.POST:
     username = request.POST['username']
     password = request.POST['password']
@@ -34,10 +39,7 @@
         # Return a 'disabled account' error message
     else:
       # Return an 'invalid login' error message.
-      pass
-  else:
-    context = {}
-    template = 'projrev/auth/login.html'
+      context['error'] = True
 
   return render_to_response(template, context)
 
@@ -87,4 +89,6 @@
 def logout_view(request):
   """Logout the user
   """
-  
\ No newline at end of file
+
+  logout(request)
+  return HttpResponseRedirect(reverse('app.projrev.views.base.home'))