Redirect to repository pages if the repository exists, and it's public or the user has read access, and the route doesn't match any other route.

This commit is contained in:
Jake Moshenko 2014-11-20 15:12:37 -05:00
parent e6742b00b0
commit 768a60b414

View file

@ -10,8 +10,8 @@ from health.healthcheck import HealthCheck
from data import model
from data.model.oauth import DatabaseAuthorizationProvider
from app import app, billing as stripe, build_logs
from auth.auth import require_session_login
from auth.permissions import AdministerOrganizationPermission
from auth.auth import require_session_login, process_oauth
from auth.permissions import AdministerOrganizationPermission, ReadRepositoryPermission
from util.invoice import renderInvoiceToPdf
from util.seo import render_snapshot
from util.cache import no_cache
@ -206,6 +206,21 @@ def robots():
return send_from_directory('static', 'robots.txt')
@web.route('/<path:repository>')
@no_cache
@process_oauth
@parse_repository_name
def redirect_to_repository(namespace, reponame):
permission = ReadRepositoryPermission(namespace, reponame)
is_public = model.repository_is_public(namespace, reponame)
if permission.can() or is_public:
repository_name = '/'.join([namespace, reponame])
return redirect(url_for('web.repository', path=repository_name))
abort(404)
@web.route('/receipt', methods=['GET'])
@route_show_if(features.BILLING)
@require_session_login