diff --git a/blti/views/__init__.py b/blti/views/__init__.py index f84f5a7..7a403d3 100644 --- a/blti/views/__init__.py +++ b/blti/views/__init__.py @@ -16,7 +16,7 @@ def get(self, request, *args, **kwargs): params = self.validate(request) except BLTIException as err: self.template_name = 'blti/401.html' - return self.render_to_response({}) + return self.render_to_response({}, status=401) context = self.get_context_data( request=request, blti_params=params, **kwargs) @@ -55,7 +55,7 @@ def post(self, request, *args, **kwargs): self.set_session(request, **params) except BLTIException as err: self.template_name = 'blti/error.html' - return self.render_to_response({'error': err}) + return self.render_to_response({'error': err}, status=400) context = self.get_context_data( request=request, blti_params=params, **kwargs) @@ -67,11 +67,11 @@ def post(self, request, *args, **kwargs): def validate(self, request): params = {} body = request.read() - if body and len(body): + try: params = dict((k, v) for k, v in [tuple( map(unquote_plus, kv.split('=')) ) for kv in body.split('&')]) - else: + except Exception: raise BLTIException('Missing or malformed parameter or value') blti_params = BLTIOauth().validate(request, params=params)