app/projrev/views/login.py
changeset 0 c94bd9ae70d2
child 1 324233b04d76
equal deleted inserted replaced
-1:000000000000 0:c94bd9ae70d2
       
     1 """This module contains the views for the login for the portal.
       
     2 """
       
     3 
       
     4 
       
     5 __authors__ = [
       
     6   '"Madhusudan.C.S" <madhusudancs@gmail.com>',
       
     7 ]
       
     8 
       
     9 
       
    10 from django.contrib.auth import authenticate, login
       
    11 from django.shortcuts import render_to_response, get_object_or_404
       
    12 
       
    13 
       
    14 def login_validate(request):
       
    15   """Validate the user and log him in.
       
    16   """
       
    17 
       
    18   username = request.POST['username']
       
    19   password = request.POST['password']
       
    20   user = authenticate(username=username, password=password)
       
    21   if user is not None:
       
    22     if user.is_active:
       
    23       login(request, user)
       
    24         # Redirect to a success page.
       
    25     else:
       
    26       pass
       
    27       # Return a 'disabled account' error message
       
    28   else:
       
    29     # Return an 'invalid login' error message.
       
    30     pass
       
    31 
       
    32 def logout_view(request):
       
    33   """Logout the user
       
    34   """
       
    35