From 6d2270d931b2bac333194d8372de78501f682d4b Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 10 Mar 2019 12:54:32 +0100 Subject: [PATCH] Fixes for Oauth --- cps/admin.py | 8 +++++--- cps/oauth_bb.py | 13 +++++++------ cps/templates/config_view_edit.html | 2 +- cps/templates/user_edit.html | 15 ++++++++------- cps/web.py | 8 +++++--- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 38a0d59e..9b7402c5 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -172,6 +172,11 @@ def view_configuration(): # Mature Content configuration if "config_mature_content_tags" in to_save: content.config_mature_content_tags = to_save["config_mature_content_tags"].strip() + if "Show_mature_content" in to_save: + content.config_default_show = content.config_default_show + ub.MATURE_CONTENT + + if "config_authors_max" in to_save: + content.config_authors_max = int(to_save["config_authors_max"]) # Default user configuration content.config_default_role = 0 @@ -196,9 +201,6 @@ def view_configuration(): val += int(key[5:]) content.config_default_show = val - - if "Show_mature_content" in to_save: - content.config_default_show = content.config_default_show + ub.MATURE_CONTENT ub.session.commit() flash(_(u"Calibre-Web configuration updated"), category="success") config.loadSettings() diff --git a/cps/oauth_bb.py b/cps/oauth_bb.py index 75a30bbf..fb4ba60c 100644 --- a/cps/oauth_bb.py +++ b/cps/oauth_bb.py @@ -223,11 +223,12 @@ if ub.oauth_support: except Exception as e: app.logger.exception(e) ub.session.rollback() - if config.config_public_reg: - return redirect(url_for('web.register')) - else: - flash(_(u"Public registration is not enabled"), category="error") - redirect(url_for(redirect_url)) + return redirect(url_for('web.login')) + #if config.config_public_reg: + # return redirect(url_for('web.register')) + #else: + # flash(_(u"Public registration is not enabled"), category="error") + # return redirect(url_for(redirect_url)) except NoResultFound: return redirect(url_for(redirect_url)) @@ -306,7 +307,7 @@ if ub.oauth_support: return unlink_oauth(github_blueprint.name) - @oauth.route('/google') + @oauth.route('/login/google') @google_oauth_required def google_login(): if not google.authorized: diff --git a/cps/templates/config_view_edit.html b/cps/templates/config_view_edit.html index c92f888a..ff71aa8a 100644 --- a/cps/templates/config_view_edit.html +++ b/cps/templates/config_view_edit.html @@ -29,7 +29,7 @@
- +
diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index 01b2b2c3..ad8435bc 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -35,6 +35,7 @@ {% endfor %}
+
+ {% if registered_oauth.keys()| length > 0 %} -
- -
{% for oauth, name in registered_oauth.iteritems() %} - +
+ {% if oauth not in oauth_status %} - Link +
{{_('Link')}}
{% else %} - {{_('Unlink')}} +
{{_('Unlink')}}
{% endif %} -
{% endfor %}
+ {% endif %} +
{% for element in sidebar %} {% if element['config_show'] %} diff --git a/cps/web.py b/cps/web.py index 86786037..e64998d4 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1527,7 +1527,8 @@ def profile(): if config.config_public_reg and not check_valid_domain(to_save["email"]): flash(_(u"E-mail is not from valid domain"), category="error") return render_title_template("user_edit.html", content=current_user, downloads=downloads, - title=_(u"%(name)s's profile", name=current_user.nickname)) + title=_(u"%(name)s's profile", name=current_user.nickname), page="me", + registered_oauth=oauth_check, oauth_status=oauth_status) current_user.email = to_save["email"] if "show_random" in to_save and to_save["show_random"] == "on": current_user.random_books = 1 @@ -1552,8 +1553,9 @@ def profile(): ub.session.rollback() flash(_(u"Found an existing account for this e-mail address."), category="error") return render_title_template("user_edit.html", content=current_user, downloads=downloads, - title=_(u"%(name)s's profile", name=current_user.nickname, - registered_oauth=oauth_check, oauth_status=oauth_status)) + translations=translations, + title=_(u"%(name)s's profile", name=current_user.nickname), page="me", + registered_oauth=oauth_check, oauth_status=oauth_status) flash(_(u"Profile updated"), category="success") return render_title_template("user_edit.html", translations=translations, profile=1, languages=languages, content=current_user, downloads=downloads, title=_(u"%(name)s's profile",