From 9a6d5761ee5b79ab9203e55a74bd2614eeabab04 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 14 Sep 2022 22:47:31 +0200 Subject: [PATCH] Reset password: mail case insensitive --- app/auth/routes.py | 11 ++++++----- app/scodoc/sco_archives.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/auth/routes.py b/app/auth/routes.py index 6263ef35..b1a0c41d 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -6,6 +6,7 @@ auth.routes.py from flask import current_app, flash, render_template from flask import redirect, url_for, request from flask_login import login_user, logout_user, current_user +from sqlalchemy import func from app import db from app.auth import bp @@ -79,18 +80,18 @@ def reset_password_request(): return redirect(url_for("scodoc.index")) form = ResetPasswordRequestForm() if form.validate_on_submit(): - users = User.query.filter_by(email=form.email.data).all() + users = User.query.filter( + func.lower(User.email) == func.lower(form.email.data) + ).all() if len(users) == 1: send_password_reset_email(users[0]) elif len(users) > 1: current_app.logger.info( - "reset_password_request: multiple users with email '{}' (ignoring)".format( - form.email.data - ) + f"reset_password_request: multiple users with email '{form.email.data}' (ignoring)" ) else: current_app.logger.info( - "reset_password_request: for unkown user '{}'".format(form.email.data) + f"reset_password_request: for unkown user '{form.email.data}'" ) flash( _("Voir les instructions envoyées par mail (pensez à regarder vos spams)") diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index 4fd49b41..ac795578 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -197,7 +197,7 @@ class BaseArchiver(object): """returns archive id (check that name is valid)""" self.initialize() if not self.is_valid_archive_name(archive_name): - raise ValueError("invalid archive name") + raise ScoValueError(f"Archive {archive_name} introuvable") archive_id = os.path.join(self.get_obj_dir(oid), archive_name) if not os.path.isdir(archive_id): log(