Fixes for Oauth

pull/932/head
Ozzieisaacs 6 years ago
parent 1db1c2e7df
commit 6d2270d931

@ -172,6 +172,11 @@ def view_configuration():
# Mature Content configuration # Mature Content configuration
if "config_mature_content_tags" in to_save: if "config_mature_content_tags" in to_save:
content.config_mature_content_tags = to_save["config_mature_content_tags"].strip() 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 # Default user configuration
content.config_default_role = 0 content.config_default_role = 0
@ -196,9 +201,6 @@ def view_configuration():
val += int(key[5:]) val += int(key[5:])
content.config_default_show = val 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() ub.session.commit()
flash(_(u"Calibre-Web configuration updated"), category="success") flash(_(u"Calibre-Web configuration updated"), category="success")
config.loadSettings() config.loadSettings()

@ -223,11 +223,12 @@ if ub.oauth_support:
except Exception as e: except Exception as e:
app.logger.exception(e) app.logger.exception(e)
ub.session.rollback() ub.session.rollback()
if config.config_public_reg: return redirect(url_for('web.login'))
return redirect(url_for('web.register')) #if config.config_public_reg:
else: # return redirect(url_for('web.register'))
flash(_(u"Public registration is not enabled"), category="error") #else:
redirect(url_for(redirect_url)) # flash(_(u"Public registration is not enabled"), category="error")
# return redirect(url_for(redirect_url))
except NoResultFound: except NoResultFound:
return redirect(url_for(redirect_url)) return redirect(url_for(redirect_url))
@ -306,7 +307,7 @@ if ub.oauth_support:
return unlink_oauth(github_blueprint.name) return unlink_oauth(github_blueprint.name)
@oauth.route('/google') @oauth.route('/login/google')
@google_oauth_required @google_oauth_required
def google_login(): def google_login():
if not google.authorized: if not google.authorized:

@ -29,7 +29,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="config_authors_max">{{_('No. of authors to show before hiding (0=disable hiding)')}}</label> <label for="config_authors_max">{{_('No. of authors to show before hiding (0=disable hiding)')}}</label>
<input type="number" min="0" max="999" class="form-control" name="config_authors_max" id="config_authors_max" value="{% if content.config_authors_max != None %}{{ content.config_authors_max }}{% endif %}" autocomplete="off"> <input type="number" min="0" max="999" class="form-control" name="config_authors_max" id="config_authors_max" value="{% if conf.config_authors_max != None %}{{ conf.config_authors_max }}{% endif %}" autocomplete="off">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="config_theme">{{_('Theme')}}</label> <label for="config_theme">{{_('Theme')}}</label>

@ -35,6 +35,7 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="default_language">{{_('Show books with language')}}</label> <label for="default_language">{{_('Show books with language')}}</label>
<select name="default_language" id="default_language" class="form-control"> <select name="default_language" id="default_language" class="form-control">
@ -44,21 +45,21 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
{% if registered_oauth.keys()| length > 0 %} {% if registered_oauth.keys()| length > 0 %}
<div class="form-group">
<label for="oauth_settings">{{_('OAuth Settings')}}</label>
<br/>
{% for oauth, name in registered_oauth.iteritems() %} {% for oauth, name in registered_oauth.iteritems() %}
<label for="config_{{ oauth }}_oauth" style="margin-left: 15px">{{ name }}</label> <div class="form-group">
<label>{{ name }} {{_('OAuth Settings')}}</label>
{% if oauth not in oauth_status %} {% if oauth not in oauth_status %}
<a href="/cw/github" target="_blank" style="margin-left: 5px">Link</a> <!-- ToDo: Not really working--> <div><a href="{{ url_for(oauth +'.login') }}" id="config_{{ oauth }}_oauth" class="btn btn-primary">{{_('Link')}}</a></div>
{% else %} {% else %}
<a href="{{ url_for('oauth.github_login_unlink') }}" style="margin-left: 5px">{{_('Unlink')}}</a> <!-- ToDo: Google not working--> <div><a href="{{ url_for('oauth.'+ oauth +'_login_unlink') }}" id="config_{{ oauth }}_oauth" class="btn btn-primary">{{_('Unlink')}}</a></div>
{% endif %} {% endif %}
<br/>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
<div class="col-sm-6"> <div class="col-sm-6">
{% for element in sidebar %} {% for element in sidebar %}
{% if element['config_show'] %} {% if element['config_show'] %}

@ -1527,7 +1527,8 @@ def profile():
if config.config_public_reg and not check_valid_domain(to_save["email"]): if config.config_public_reg and not check_valid_domain(to_save["email"]):
flash(_(u"E-mail is not from valid domain"), category="error") flash(_(u"E-mail is not from valid domain"), category="error")
return render_title_template("user_edit.html", content=current_user, downloads=downloads, 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"] current_user.email = to_save["email"]
if "show_random" in to_save and to_save["show_random"] == "on": if "show_random" in to_save and to_save["show_random"] == "on":
current_user.random_books = 1 current_user.random_books = 1
@ -1552,8 +1553,9 @@ def profile():
ub.session.rollback() ub.session.rollback()
flash(_(u"Found an existing account for this e-mail address."), category="error") 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, return render_title_template("user_edit.html", content=current_user, downloads=downloads,
title=_(u"%(name)s's profile", name=current_user.nickname, translations=translations,
registered_oauth=oauth_check, oauth_status=oauth_status)) 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") flash(_(u"Profile updated"), category="success")
return render_title_template("user_edit.html", translations=translations, profile=1, languages=languages, return render_title_template("user_edit.html", translations=translations, profile=1, languages=languages,
content=current_user, downloads=downloads, title=_(u"%(name)s's profile", content=current_user, downloads=downloads, title=_(u"%(name)s's profile",

Loading…
Cancel
Save