Skip to content

Commit

Permalink
fix register frontend flow
Browse files Browse the repository at this point in the history
  • Loading branch information
dqian3 committed Nov 7, 2024
1 parent a0927f6 commit 3fccd02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions apis/users_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ def create_user():

cursor.execute(get_id_query)
(id,) = cursor.fetchone()

_send_confirmation_email(id, email, username, request.url_root, on_signup=True)

if "MAIL_SERVER" in current_app.config:
_send_confirmation_email(id, email, username, request.url_root, on_signup=True)

db.commit()

Expand Down
6 changes: 5 additions & 1 deletion frontend/templates/users/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
document.getElementById("loginForm").reset();
validationAlert("Successfully logged in!", false);

window.location.href = document.referrer || "/";
if (!document.referrer || document.referrer.endsWith("/register"))
window.location.href = "/";
else
window.location.href = document.referrer;

} else if (response.status == 401) {
validationAlert("Invalid username or password");
} else {
Expand Down
4 changes: 2 additions & 2 deletions frontend/templates/users/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
document.getElementById("registerForm").reset();
validationAlert("Successfully Registered!", false);
setTimeout(() => {
window.location.href = "/login";
}, 2000);
window.location.replace("/login");
}, 500);
} else if (response.status == 409) {
validationAlert("User already exists");
} else {
Expand Down

0 comments on commit 3fccd02

Please sign in to comment.