fix change name allowd as non admin

This commit is contained in:
Ozzie Isaacs 2021-07-23 19:34:46 +02:00
parent 20fa9f5523
commit 3c8bfc31e4
2 changed files with 37 additions and 36 deletions

View File

@ -75,7 +75,6 @@
</div>
{% endif %}
{% endfor %}
<div class="form-group">
<input type="checkbox" name="Show_detail_random" id="Show_detail_random" {% if content.show_detail_random() %}checked{% endif %}>
<label for="Show_detail_random">{{_('Show Random Books in Detail View')}}</label>
@ -85,6 +84,7 @@
<a href="#" id="get_user_column_values" data-id="{{content.id}}" class="btn btn-default" data-toggle="modal" data-target="#restrictModal">{{_('Add allowed/Denied Custom Column Values')}}</a>
{% endif %}
</div>
</div>
<div class="col-sm-6">
{% if g.user and g.user.role_admin() and not profile %}
{% if not content.role_anonymous() %}
@ -143,7 +143,7 @@
</form>
</div>
<div class="modal fade" id="modal_kobo_token" tabindex="-1" role="dialog" aria-labelledby="kobo_tokenModalLabel">
<div class="modal fade" id="modal_kobo_token" tabindex="-1" role="dialog" aria-labelledby="kobo_tokenModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
@ -156,7 +156,7 @@
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block modal %}

View File

@ -1580,19 +1580,20 @@ def logout():
# ################################### Users own configuration #########################################################
def change_profile(kobo_support, local_oauth_check, oauth_status, translations, languages):
def change_profile(kobo_support, local_oauth_check, oauth_status):
to_save = request.form.to_dict()
current_user.random_books = 0
if current_user.role_passwd() or current_user.role_admin():
if to_save.get("password"):
current_user.password = generate_password_hash(to_save["password"])
try:
if to_save.get("allowed_tags", current_user.allowed_tags) != current_user.allowed_tags:
current_user.allowed_tags = to_save["allowed_tags"].strip()
if to_save.get("kindle_mail", current_user.kindle_mail) != current_user.kindle_mail:
current_user.kindle_mail = valid_email(to_save["kindle_mail"])
if to_save.get("email", current_user.email) != current_user.email:
current_user.email = check_email(to_save["email"])
if current_user.role_admin():
if to_save.get("allowed_tags", current_user.allowed_tags) != current_user.allowed_tags:
current_user.allowed_tags = to_save["allowed_tags"].strip()
if to_save.get("name", current_user.name) != current_user.name:
# Query User name, if not existing, change
current_user.name = check_username(to_save["name"])
@ -1646,7 +1647,7 @@ def profile():
local_oauth_check = {}
if request.method == "POST":
change_profile(kobo_support, local_oauth_check, oauth_status, translations, languages)
change_profile(kobo_support, local_oauth_check, oauth_status)
return render_title_template("user_edit.html",
translations=translations,
profile=1,