From 0cc07362b88dc8b1cadf4c38a186ef07e0b13cf0 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Fri, 21 Aug 2020 19:26:58 +0200 Subject: [PATCH] Fix for #1573 --- cps/gdriveutils.py | 8 ++++++-- cps/oauth_bb.py | 4 ++-- cps/templates/config_edit.html | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 683605ff..a996f879 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -602,8 +602,12 @@ def get_error_text(client_secrets=None): if not os.path.isfile(CLIENT_SECRETS): return 'client_secrets.json is missing or not readable' - with open(CLIENT_SECRETS, 'r') as settings: - filedata = json.load(settings) + try: + with open(CLIENT_SECRETS, 'r') as settings: + filedata = json.load(settings) + except PermissionError: + return 'client_secrets.json is missing or not readable' + if 'web' not in filedata: return 'client_secrets.json is not configured for web application' if 'redirect_uris' not in filedata['web']: diff --git a/cps/oauth_bb.py b/cps/oauth_bb.py index d98ec50a..3777d751 100644 --- a/cps/oauth_bb.py +++ b/cps/oauth_bb.py @@ -287,7 +287,7 @@ if ub.oauth_support: flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error") except NoResultFound: log.warning("oauth %s for user %d not found", provider, current_user.id) - flash(_(u"Not Linked to %(oauth)s.", oauth=oauth_check[provider]), category="error") + flash(_(u"Not Linked to %(oauth)s", oauth=provider), category="error") return redirect(url_for('web.profile')) @@ -355,4 +355,4 @@ if ub.oauth_support: @oauth.route('/unlink/google', methods=["GET"]) @login_required def google_login_unlink(): - return unlink_oauth(oauthblueprints[1]['blueprint'].name) + return unlink_oauth(oauthblueprints[1]['id']) diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index 6cb95764..2d1ae560 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -30,20 +30,20 @@
{% if gdriveError %}
-
{% else %} {% if show_authenticate_google_drive and g.user.is_authenticated and config.config_use_google_drive %} {% else %} {% if show_authenticate_google_drive and g.user.is_authenticated and not config.config_use_google_drive %}
{{_('Please hit save to continue with setup')}}
{% endif %} - {% if not g.user.is_authenticated %} + {% if not g.user.is_authenticated and show_login_button %}
{{_('Please finish Google Drive setup after login')}}
{% endif %} {% if g.user.is_authenticated %}