Commit ac470a0a authored by Sofia Papagiannaki's avatar Sofia Papagiannaki

pithos views: In case of invalid access token request a new one

Instead of raising PermissionDenied redirect to the
object view url to re-initiate the procedure
for acquiring a new access token.
parent 09918406
......@@ -1138,8 +1138,11 @@ def view_method():
logger=logger)
if access_token is not None:
# authenticate using the short-term access token
request.user = astakos.validate_token(access_token,
requested_resource)
try:
request.user = astakos.validate_token(
access_token, requested_resource)
except AstakosClientException:
return HttpResponseRedirect(request.path)
request.user_uniq = request.user["access"]["user"]["id"]
_func = api_method(token_required=False,
......@@ -1147,7 +1150,7 @@ def view_method():
response = _func(request, *args, **kwargs)
if response.status_code == 404:
raise Http404
elif response.status_code in [401, 403]:
elif response.status_code == 403:
raise PermissionDenied
return response
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment