Esempio n. 1
0
    def post(self, request):
        parse_distutils_request(request)

        # XXX: Auth is currently a bit of a hack
        method, identity = split_auth(request)
        if not method:
            return HttpResponseUnauthorized(content='Missing auth header')

        user = authenticate_user(request)
        if not user:
            return HttpResponse('Invalid username/password', status=401)

        actions = {
            'submit': handle_register_or_upload,
            'file_upload': handle_register_or_upload,
        }

        handler = actions.get(request.POST.get(':action'))
        if not handler:
            raise Http404('Unknown action')
        return handler(request.POST, request.FILES, user)
Esempio n. 2
0
    def post(self, request):
        data, files = parse_distutils_request(request)

        # XXX: Auth is currently a bit of a hack
        method, identity = split_auth(request)
        if not method:
            return HttpResponseUnauthorized('Missing auth header')

        username, password = decode_credentials(identity)
        user = authenticate(username=username, password=password)
        if not user:
            return HttpResponse('Invalid username/password', status=401)

        actions = {
            'submit': handle_register_or_upload,
            'file_upload': handle_register_or_upload,
        }

        handler = actions.get(data.get(':action'))
        if not handler:
            raise Http404('Unknown action')
        return handler(data, files, user)