aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2020-01-19 19:48:41 +0000
committerrubenwardy <rw@rubenwardy.com>2020-01-19 19:48:41 +0000
commite115b0678cce0f918e1985524751f95c21dd2b2d (patch)
tree601e7b08c007d253bb2cf379f313c640ccb0e7e4 /app/blueprints
parent0bda16de6dae7a684acf4332312765fe2d78741c (diff)
downloadcheatdb-e115b0678cce0f918e1985524751f95c21dd2b2d.tar.xz
Fix password issues caused by Flask-User migration
Diffstat (limited to 'app/blueprints')
-rw-r--r--app/blueprints/users/githublogin.py2
-rw-r--r--app/blueprints/users/profile.py9
2 files changed, 6 insertions, 5 deletions
diff --git a/app/blueprints/users/githublogin.py b/app/blueprints/users/githublogin.py
index 56c4412..a029361 100644
--- a/app/blueprints/users/githublogin.py
+++ b/app/blueprints/users/githublogin.py
@@ -65,7 +65,7 @@ def github_authorized(oauth_token):
flash("Unable to find an account for that Github user", "error")
return redirect(url_for("users.claim"))
elif loginUser(userByGithub):
- if current_user.password is None:
+ if not current_user.hasPassword():
return redirect(next_url or url_for("users.set_password", optional=True))
else:
return redirect(next_url or url_for("homepage.home"))
diff --git a/app/blueprints/users/profile.py b/app/blueprints/users/profile.py
index 8e6bfe9..37ea992 100644
--- a/app/blueprints/users/profile.py
+++ b/app/blueprints/users/profile.py
@@ -170,7 +170,7 @@ class SetPasswordForm(FlaskForm):
@bp.route("/user/set-password/", methods=["GET", "POST"])
@login_required
def set_password():
- if current_user.password is not None:
+ if current_user.hasPassword():
return redirect(url_for("user.change_password"))
form = SetPasswordForm(request.form)
@@ -185,10 +185,11 @@ def set_password():
hashed_password = user_manager.hash_password(form.password.data)
# Change password
- user_manager.update_password(current_user, hashed_password)
+ current_user.password = hashed_password
+ db.session.commit()
# Send 'password_changed' email
- if user_manager.enable_email and user_manager.send_password_changed_email and current_user.email:
+ if user_manager.USER_ENABLE_EMAIL and current_user.email:
emails.send_password_changed_email(current_user)
# Send password_changed signal
@@ -211,7 +212,7 @@ def set_password():
task = sendVerifyEmail.delay(newEmail, token)
return redirect(url_for("tasks.check", id=task.id, r=url_for("users.profile", username=current_user.username)))
else:
- return redirect(url_for("users.profile", username=current_user.username))
+ return redirect(url_for("user.login"))
else:
flash("Passwords do not match", "error")