Catch an error when trying to generate an access token.

This commit is contained in:
yackob03 2013-11-11 17:01:21 -05:00
parent 2e9f7cd19d
commit 3187539509

View file

@ -33,10 +33,14 @@ def generate_headers(role='read'):
if has_token_request:
repo = model.get_repository(namespace, repository)
token = model.create_access_token(repo, role)
token_str = 'signature=%s' % token.code
response.headers['WWW-Authenticate'] = token_str
response.headers['X-Docker-Token'] = token_str
if repo:
token = model.create_access_token(repo, role)
token_str = 'signature=%s' % token.code
response.headers['WWW-Authenticate'] = token_str
response.headers['X-Docker-Token'] = token_str
else:
logger.info('Token request in non-existing repo: %s/%s' %
(namespace, repository))
return response
return wrapper