Skip to content

Commit

Permalink
Add redirects to login/signup
Browse files Browse the repository at this point in the history
  • Loading branch information
amCap1712 committed Jan 11, 2024
1 parent 2af38d0 commit 75c157d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 5 additions & 2 deletions frontend/js/src/forms/LoginUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ function LoginUser({
<div className="auth-card-footer">
<div className="small">
Don‘t have an account?
<a href="/Login"> Create a free MetaBrainz account </a>to access
MusicBrainz, ListenBrainz, CritiqueBrainz, and more.
<a href={`/signup${window.location.search}`}>
{" "}
Create a free MetaBrainz account{" "}
</a>
to access MusicBrainz, ListenBrainz, CritiqueBrainz, and more.
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion frontend/js/src/forms/SignupUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ function SignupUser({
</div>
<div className="auth-card-footer">
<div className="small">
Already have an account? <a href="/login">Sign in </a>
Already have an account?{" "}
<a href={`/login${window.location.search}`}>Sign in </a>
</div>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions metabrainz/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def signup():
)
login_user(user)
flash.success("Account created. Please check your inbox to complete verification.")
return redirect(url_for("index.home"))
redirect_to = request.args.get("next")
if not redirect_to:
redirect_to = url_for("index.home")
return redirect(redirect_to)

form_errors = {k: ". ".join(v) for k, v in form.errors.items()}
form_data = dict(**form.data)
Expand Down Expand Up @@ -69,7 +72,10 @@ def login():
else:
login_user(user, remember=form.remember_me.data)
flash.success("Logged in successfully.")
return redirect(url_for("index.home"))
redirect_to = request.args.get("next")
if not redirect_to:
redirect_to = url_for("index.home")
return redirect(redirect_to)

form_errors = {k: ". ".join(v) for k, v in form.errors.items()}
form_data = dict(**form.data)
Expand Down

0 comments on commit 75c157d

Please sign in to comment.