From 0aa3ff4f6deae3cc5038d70d200946473213b158 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sat, 12 Nov 2016 21:28:40 +0100 Subject: [PATCH] Remove trailing spaces from username during login Upload of books working on windows without errors --- cps/helper.py | 8 ++++---- cps/web.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index d1213d13..0fd9b95e 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -192,20 +192,20 @@ def update_dir_stucture(book_id): book = db.session.query(db.Books).filter(db.Books.id == book_id).first() path = os.path.join(config.DB_ROOT, book.path) - authordir = book.path.split("/")[0] + authordir = book.path.split(os.sep)[0] new_authordir=get_valid_filename(book.authors[0].name, False) - titledir = book.path.split("/")[1] + titledir = book.path.split(os.sep)[1] new_titledir = get_valid_filename(book.title, False) + " (" + str(book_id) + ")" if titledir != new_titledir: new_title_path = os.path.join(os.path.dirname(path), new_titledir) os.rename(path, new_title_path) path = new_title_path - book.path = book.path.split("/")[0] + "/" + new_titledir + book.path = book.path.split(os.sep)[0] + os.sep + new_titledir if authordir != new_authordir: new_author_path = os.path.join(os.path.join(config.DB_ROOT, new_authordir), os.path.basename(path)) os.renames(path, new_author_path) - book.path = new_authordir + "/" + book.path.split("/")[1] + book.path = new_authordir + os.sep + book.path.split(os.sep)[1] db.session.commit() diff --git a/cps/web.py b/cps/web.py index 618e1c11..2512fd94 100755 --- a/cps/web.py +++ b/cps/web.py @@ -983,7 +983,7 @@ def login(): if request.method == "POST": form = request.form.to_dict() - user = ub.session.query(ub.User).filter(ub.User.nickname == form['username']).first() + user = ub.session.query(ub.User).filter(ub.User.nickname == form['username'].strip()).first() if user and check_password_hash(user.password, form['password']): login_user(user, remember = True)