mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 09:30:31 +00:00
Fixes for Oauth
This commit is contained in:
parent
1db1c2e7df
commit
6d2270d931
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -29,7 +29,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<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 class="form-group">
|
||||
<label for="config_theme">{{_('Theme')}}</label>
|
||||
|
@ -35,6 +35,7 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="default_language">{{_('Show books with language')}}</label>
|
||||
<select name="default_language" id="default_language" class="form-control">
|
||||
@ -44,21 +45,21 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% 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() %}
|
||||
<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 %}
|
||||
<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 %}
|
||||
<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 %}
|
||||
<br/>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<div class="col-sm-6">
|
||||
{% for element in sidebar %}
|
||||
{% if element['config_show'] %}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user