daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jun 5th, 2017 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.template import Context, loader, RequestContext
  2. from django.shortcuts import render_to_response
  3. from django.contrib.auth import authenticate
  4. from django.contrib.auth.views import logout, login
  5. from django.contrib.auth.decorators import login_required
  6. from django.http import HttpResponse, HttpResponseRedirect
  7.  
  8.  
  9. @login_required
  10. def index(request):
  11.         return render_to_response('index.html')
  12.  
  13.  
  14. def auth_login(request):
  15.  
  16.     if request.user.id:
  17.         return render_to_response('index.html',context_instance=RequestContext(request))
  18.    
  19.     if request.method == "POST":
  20.         agent = request.POST.get('alias')
  21.         agent_password = request.POST.get('password')
  22.         u = authenticate(username=agent, password=agent_password)
  23.         if u is not None:
  24.             if u.is_active:
  25.                 login(request, u)
  26.  
  27.                 if request.POST.get('next'):
  28.                     return HttpResponseRedirect(request.POST.get('next'))
  29.  
  30.  
  31.             return render_to_response('index.html',context_instance=RequestContext(request))
  32.        
  33.     return render_to_response('login.html',context_instance=RequestContext(request))
  34.  
  35.  
  36. def auth_logout(request):
  37.     logout(request)
  38.     return render_to_response('index.html',context_instance=RequestContext(request))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top