2013-01-24 13:44:43 -05:00
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.contrib.auth.decorators import login_required
|
2013-01-24 14:11:11 -05:00
|
|
|
from django.contrib.auth import authenticate, login
|
2013-01-24 13:44:43 -05:00
|
|
|
from django.template import RequestContext
|
2013-01-24 14:11:11 -05:00
|
|
|
from django.shortcuts import render_to_response, redirect
|
2013-01-24 13:44:43 -05:00
|
|
|
|
|
|
|
@login_required
|
|
|
|
def main(request):
|
|
|
|
return render_to_response("main", context_instance = RequestContext(request))
|
|
|
|
|
2013-01-24 14:11:11 -05:00
|
|
|
def login_page(request):
|
2013-01-24 13:44:43 -05:00
|
|
|
return render_to_response("login", context_instance = RequestContext(request))
|
2013-01-24 14:11:11 -05:00
|
|
|
|
|
|
|
def authenticate(request):
|
|
|
|
username = request.POST["username"]
|
|
|
|
password = request.POST["password"]
|
|
|
|
user = authenticate(username, password)
|
|
|
|
|
|
|
|
if user is not None:
|
|
|
|
if user.isactive:
|
|
|
|
login(request, user)
|
|
|
|
redirect("/")
|
|
|
|
else:
|
|
|
|
#User is inactive
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
#Authentication failed
|
|
|
|
pass
|