Bugfixes create users

Update Teststatus
This commit is contained in:
Ozzie Isaacs 2022-06-17 10:14:33 +02:00
parent 4ef8c35fb7
commit 29fd4ae4a2
4 changed files with 9170 additions and 2300 deletions

View File

@ -1849,10 +1849,10 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support):
content.role = constants.selected_roles(to_save) content.role = constants.selected_roles(to_save)
try: try:
content.password = generate_password_hash(helper.valid_password(to_save["password"]))
if not to_save["name"] or not to_save["email"] or not to_save["password"]: if not to_save["name"] or not to_save["email"] or not to_save["password"]:
log.info("Missing entries on new user") log.info("Missing entries on new user")
raise Exception(_(u"Please fill out all fields!")) raise Exception(_(u"Please fill out all fields!"))
content.password = generate_password_hash(helper.valid_password(to_save.get("password", "")))
content.email = check_email(to_save["email"]) content.email = check_email(to_save["email"])
# Query username, if not existing, change # Query username, if not existing, change
content.name = check_username(to_save["name"]) content.name = check_username(to_save["name"])
@ -1936,8 +1936,6 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support):
log.warning("No admin user remaining, can't remove admin role from {}".format(content.name)) log.warning("No admin user remaining, can't remove admin role from {}".format(content.name))
flash(_("No admin user remaining, can't remove admin role"), category="error") flash(_("No admin user remaining, can't remove admin role"), category="error")
return redirect(url_for('admin.admin')) return redirect(url_for('admin.admin'))
if 'password' in to_save:
content.password = generate_password_hash(helper.valid_password(to_save('password')))
anonymous = content.is_anonymous anonymous = content.is_anonymous
content.role = constants.selected_roles(to_save) content.role = constants.selected_roles(to_save)
if anonymous: if anonymous:
@ -1971,6 +1969,8 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support):
if to_save.get("locale"): if to_save.get("locale"):
content.locale = to_save["locale"] content.locale = to_save["locale"]
try: try:
if to_save.get('password', "") != "":
content.password = generate_password_hash(helper.valid_password(to_save['password']))
if to_save.get("email", content.email) != content.email: if to_save.get("email", content.email) != content.email:
content.email = check_email(to_save["email"]) content.email = check_email(to_save["email"])
# Query username, if not existing, change # Query username, if not existing, change

View File

@ -1358,8 +1358,8 @@ def change_profile(kobo_support, local_oauth_check, oauth_status, translations,
current_user.random_books = 0 current_user.random_books = 0
try: try:
if current_user.role_passwd() or current_user.role_admin(): if current_user.role_passwd() or current_user.role_admin():
if 'password' in to_save: if to_save.get('password', "") != "":
current_user.password = generate_password_hash(valid_password(to_save('password'))) current_user.password = generate_password_hash(valid_password(to_save['password']))
if to_save.get("kindle_mail", current_user.kindle_mail) != current_user.kindle_mail: if to_save.get("kindle_mail", current_user.kindle_mail) != current_user.kindle_mail:
current_user.kindle_mail = valid_email(to_save.get("kindle_mail")) current_user.kindle_mail = valid_email(to_save.get("kindle_mail"))
if to_save.get("email", current_user.email) != current_user.email: if to_save.get("email", current_user.email) != current_user.email:

View File

@ -97,5 +97,5 @@ comics =
natsort>=2.2.0,<8.2.0 natsort>=2.2.0,<8.2.0
comicapi>=2.2.0,<2.3.0 comicapi>=2.2.0,<2.3.0
kobo = kobo =
jsonschema>=3.2.0,<4.6.0 jsonschema>=3.2.0,<4.7.0

File diff suppressed because it is too large Load Diff