Ejemplo n.º 1
0
def login(request):
    ret = {}
    if request.method == "POST":
        if request.POST.get('username') is not None and request.POST.get(
                'password'):
            user = auth.authenticate(username=request.POST.get('username'),
                                     password=request.POST.get('password'))
            if user is not None:
                if user.is_active:
                    auth.login(request, user)
                    ret['name'] = request.user.username
        return packageResponse(ret)
    else:
        user = request.user.username
        response = render_to_response('index.html', {'name': user})
        response.set_cookie("user", "0FAC6FBASDS3213AX")
        return response
Ejemplo n.º 2
0
 def put(self,request,fun,format=None):
     method = request.POST.get('method')
     ret = Methods.get('PUT').get(fun)(request)
     return packageResponse(ret)
Ejemplo n.º 3
0
 def post(self,request,fun,format=None):
     ret = Methods.get('POST').get(fun)(request)
     return packageResponse(ret)
Ejemplo n.º 4
0
def logout(request):
    ret = {'data': 'logout'}
    auth.logout(request)
    return packageResponse(ret)
Ejemplo n.º 5
0
 def delete(self, request, fun, format=None):
     print fun
     ret = Methods.get('DELETE').get(fun)(request)
     return packageResponse(ret)
Ejemplo n.º 6
0
 def put(self, request, fun, format=None):
     print fun
     ret = Methods.get('PUT').get(fun)(request)
     return packageResponse(ret)