diff --git a/data/model/user.py b/data/model/user.py index 3ca44f9f5..54331de3b 100644 --- a/data/model/user.py +++ b/data/model/user.py @@ -440,7 +440,7 @@ def confirm_user_email(code): code = EmailConfirmation.get(EmailConfirmation.code == code, EmailConfirmation.email_confirm == True) except EmailConfirmation.DoesNotExist: - raise DataModelException('Invalid email confirmation code.') + raise DataModelException('Invalid email confirmation code') user = code.user user.verified = True @@ -449,7 +449,7 @@ def confirm_user_email(code): new_email = code.new_email if new_email and new_email != old_email: if find_user_by_email(new_email): - raise DataModelException('E-mail address already used.') + raise DataModelException('E-mail address already used') old_email = user.email user.email = new_email @@ -465,10 +465,10 @@ def create_reset_password_email_code(email): try: user = User.get(User.email == email) except User.DoesNotExist: - raise InvalidEmailAddressException('Email address was not found.') + raise InvalidEmailAddressException('Email address was not found') if user.organization: - raise InvalidEmailAddressException('Organizations can not have passwords.') + raise InvalidEmailAddressException('Organizations can not have passwords') code = EmailConfirmation.create(user=user, pw_reset=True) return code diff --git a/endpoints/common.py b/endpoints/common.py index 19720a858..35adca062 100644 --- a/endpoints/common.py +++ b/endpoints/common.py @@ -205,18 +205,18 @@ def render_page_template(name, route_data=None, **kwargs): version_number = ' - ' + _get_version_number() resp = make_response(render_template(name, - route_data=json.dumps(route_data), + route_data=route_data, external_styles=external_styles, external_scripts=external_scripts, main_styles=add_cachebusters(main_styles), library_styles=add_cachebusters(library_styles), main_scripts=add_cachebusters(main_scripts), library_scripts=add_cachebusters(library_scripts), - feature_set=json.dumps(features.get_features()), - config_set=json.dumps(frontend_visible_config(app.config)), - oauth_set=json.dumps(get_oauth_config()), - scope_set=json.dumps(scopes.app_scopes(app.config)), - vuln_priority_set=json.dumps(PRIORITY_LEVELS), + feature_set=features.get_features(), + config_set=frontend_visible_config(app.config), + oauth_set=get_oauth_config(), + scope_set=scopes.app_scopes(app.config), + vuln_priority_set=PRIORITY_LEVELS, enterprise_logo=app.config.get('ENTERPRISE_LOGO_URL', ''), mixpanel_key=app.config.get('MIXPANEL_KEY', ''), munchkin_key=app.config.get('MARKETO_MUNCHKIN_ID', ''), diff --git a/endpoints/oauthlogin.py b/endpoints/oauthlogin.py index 1164d5df5..a750f5519 100644 --- a/endpoints/oauthlogin.py +++ b/endpoints/oauthlogin.py @@ -11,7 +11,7 @@ from app import app, analytics, get_app_url, github_login, google_login, dex_log from auth.process import require_session_login from data import model from endpoints.common import common_login, route_show_if -from endpoints.web import render_page_template_with_routedata +from endpoints.web import index from util.security.jwtutil import decode, InvalidTokenError from util.validation import generate_valid_usernames @@ -20,15 +20,17 @@ client = app.config['HTTPCLIENT'] oauthlogin = Blueprint('oauthlogin', __name__) -def render_ologin_error(service_name, - error_message='Could not load user data. The token may have expired.'): - user_creation = features.USER_CREATION and features.DIRECT_LOGIN - return render_page_template_with_routedata('ologinerror.html', - service_name=service_name, - error_message=error_message, - service_url=get_app_url(), - user_creation=user_creation) - +def render_ologin_error(service_name, error_message=None, register_redirect=False): + user_creation = bool(features.USER_CREATION and features.DIRECT_LOGIN) + error_info = { + 'reason': 'ologinerror', + 'service_name': service_name, + 'error_message': error_message or 'Could not load user data. The token may have expired', + 'service_url': get_app_url(), + 'user_creation': user_creation, + 'register_redirect': register_redirect, + } + return index('', error_info=error_info) def get_user(service, token): token_param = { @@ -81,7 +83,7 @@ def conduct_oauth_login(service, user_id, username, email, metadata={}): message = message + "\nPlease log in with your username and password and " message = message + "associate your %s account to use it in the future." % (service_name, ) - return render_ologin_error(service_name, message) + return render_ologin_error(service_name, message, register_redirect=True) except model.DataModelException as ex: return render_ologin_error(service_name, ex.message) diff --git a/endpoints/web.py b/endpoints/web.py index c19c957a1..03fec46f6 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -67,7 +67,7 @@ def internal_error_display(): @web.errorhandler(404) @web.route('/404', methods=['GET']) def not_found_error_display(e = None): - resp = index('', error_code=404) + resp = index('', error_code=404, error_info=dict(reason='notfound')) resp.status_code = 404 return resp @@ -275,12 +275,6 @@ def dbrevision_health(): return response -@web.route('/disclaimer', methods=['GET']) -@no_cache -def disclaimer(): - return render_page_template_with_routedata('disclaimer.html') - - @web.route('/robots.txt', methods=['GET']) def robots(): robots_txt = make_response(render_template('robots.txt', baseurl=get_app_url())) @@ -367,7 +361,7 @@ def confirm_repo_email(): try: record = model.repository.confirm_email_authorization_for_repo(code) except model.DataModelException as ex: - return render_page_template_with_routedata('confirmerror.html', error_message=ex.message) + return index('', error_info=dict(reason='confirmerror', error_message=ex.message)) message = """ Your E-mail address has been authorized to receive notifications for repository @@ -390,7 +384,7 @@ def confirm_email(): try: user, new_email, old_email = model.user.confirm_user_email(code) except model.DataModelException as ex: - return render_page_template_with_routedata('confirmerror.html', error_message=ex.message) + return index('', error_info=dict(reason='confirmerror', error_message=ex.message)) if new_email: send_email_changed(user.username, old_email, new_email) @@ -706,6 +700,7 @@ def redirect_to_repository(namespace_name, repo_name, tag_name): # - If the repository does exist (no access), 403 # > If the user is not a member of the namespace: 403 error_info = { + 'reason': 'notfound', 'for_repo': True, 'namespace_exists': namespace_exists, 'namespace': namespace_name, diff --git a/static/css/pages/error-view.css b/static/css/pages/error-view.css index b3984a95e..d140d7206 100644 --- a/static/css/pages/error-view.css +++ b/static/css/pages/error-view.css @@ -23,3 +23,8 @@ width: 225px; height: 205px; } + +.error-view-element h2 .fa-exclamation-triangle { + margin-right: 16px; + color: #D64456; +} \ No newline at end of file diff --git a/static/js/app.js b/static/js/app.js index 0483d621a..bdffb9451 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -214,7 +214,8 @@ quayApp.config(['$routeProvider', '$locationProvider', 'pages', function($routeP // 404/403 .route('/:catchall', 'error-view') - .route('/:catch/:all', 'error-view'); + .route('/:catch/:all', 'error-view') + .route('/:catch/:all/:things', 'error-view'); }]); // Configure compile provider to add additional URL prefixes to the sanitization list. We use diff --git a/static/js/pages/error-view.js b/static/js/pages/error-view.js index d5b03ec5b..0ed3f173a 100644 --- a/static/js/pages/error-view.js +++ b/static/js/pages/error-view.js @@ -4,13 +4,13 @@ */ angular.module('quayPages').config(['pages', function(pages) { pages.create('error-view', 'error-view.html', ErrorViewCtrl, { - 'title': '{{code}}', + 'title': '{{info.error_message || "Error"}}', 'description': 'Error', 'newLayout': false }); }]); - function ErrorViewCtrl($scope, ApiService, $routeParams, UserService) { + function ErrorViewCtrl($scope, ApiService, $routeParams, $rootScope, UserService) { $scope.info = window.__error_info; $scope.code = window.__error_code || 404; } diff --git a/static/partials/error-view.html b/static/partials/error-view.html index cefbd1562..9b0a60e15 100644 --- a/static/partials/error-view.html +++ b/static/partials/error-view.html @@ -1,6 +1,28 @@