Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! -*- coding: utf-8 -*-
- from django.template import loader
- from django.shortcuts import render_to_response
- from django.template import RequestContext, Context
- from django.db import connection
- from forms import FormRegistro, FormUsuario
- from django.contrib.auth.decorators import login_required
- from usuario.models import UsuarioProfile
- from django.http import HttpResponseForbidden, Http404, HttpResponse, HttpResponseRedirect
- from django.contrib.auth import authenticate
- def cross(request):
- html = """
- <?xml version=\"1.0\"?>\
- <cross-domain-policy>\
- <allow-access-from domain=\"*\" />\
- </cross-domain-policy>
- """
- return HttpResponse(html)
- def registrar(request):
- if request.method == 'POST':
- form = FormUsuario ( request.POST )
- valido = form.is_valid()
- if valido:
- novo_usuario = form.save()
- return HttpResponseRedirect('/index')
- else:
- form = FormUsuario()
- return render_to_response(
- 'registrar.html',
- locals(),
- context_instance=RequestContext(request),
- )
- def verificaUsuarioSenha(request):
- #if '.swf' in request.META.get('HTTP_REFERER',''):
- #if '.swf' not in request.META.get('HTTP_REFERER', ''):
- # return HttpResponseForbidden("status=nok")
- username = request.POST.get('username','')
- password = request.POST.get('password','')
- print request.POST
- print "_" * 40
- print request.GET
- print "_" * 40
- print "Debug"
- print "Method: %s" % request.method
- print "user:%s \npass:%s " % ( username ,password )
- print "Referer:%s" % request.META.get('HTTP_REFERER', None)
- print "_" * 40
- status = 'nok'
- if request.method == 'POST':
- user = authenticate(
- username = username,
- password = password
- )
- if user is not None:
- if user.is_active:
- status = 'ok'
- else:
- pass #status = 'nok'
- else:
- pass #status = 'nok'
- return HttpResponse("status=%s"%status)
- @login_required
- def index(request):
- nome = request.user.first_name
- id = request.user.id
- template = 'usuario/index.html'
- return render_to_response(template, {'nomeUsuario' : nome, 'idUsuario' : id}, context_instance=RequestContext(request))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement