fix redirection on signup

master
Aevann1 2022-08-30 21:03:49 +02:00
parent 1706b15ce6
commit 11afc5cff1
4 changed files with 26 additions and 19 deletions

View File

@ -14,7 +14,7 @@ def login_get(v):
redir = request.values.get("redirect", "/")
if redir:
redir = redir.replace("/logged_out", "").strip()
redir = redir.replace("/logged_out", "").strip().rstrip('?')
if not is_site_url(redir): redir = "/"
if v: return redirect(redir)
@ -146,7 +146,7 @@ def login_post():
redir = request.values.get("redirect")
if redir:
redir = redir.replace("/logged_out", "").strip()
redir = redir.replace("/logged_out", "").strip().rstrip('?')
if is_site_url(redir): return redirect(redir)
return redirect('/')
@ -213,12 +213,18 @@ def sign_up_get(v):
error = request.values.get("error")
redir = request.values.get("redirect", "/")
if redir:
redir = redir.replace("/logged_out", "").strip().rstrip('?')
if not is_site_url(redir): redir = "/"
return render_template("sign_up.html",
formkey=formkey,
now=now,
ref_user=ref_user,
hcaptcha=HCAPTCHA_SITEKEY,
error=error
error=error,
redirect=redir
)
@ -361,14 +367,19 @@ def sign_up_post(v):
session["lo_user"] = new_user.id
carp = get_account(CARP_ID)
new_follow = Follow(user_id=new_user.id, target_id=carp.id)
g.db.add(new_follow)
carp.stored_subscriber_count += 1
g.db.add(carp)
send_notification(carp.id, f"A new user - @{new_user.username} - has followed you automatically!")
if CARP_ID:
carp = get_account(CARP_ID)
new_follow = Follow(user_id=new_user.id, target_id=carp.id)
g.db.add(new_follow)
carp.stored_subscriber_count += 1
g.db.add(carp)
send_notification(carp.id, f"A new user - @{new_user.username} - has followed you automatically!")
return redirect(SITE_FULL)
redir = request.values.get("redirect")
if redir:
redir = redir.replace("/logged_out", "").strip().rstrip('?')
if is_site_url(redir): return redirect(redir)
return redirect('/')
@app.get("/forgot")

View File

@ -79,9 +79,8 @@
<button class="btn btn-primary login w-100 mt-3" id="login_button">Sign In</button>
<div class="text-center text-muted text-small mt-5 mb-3">
Don't have an account? <a href="/signup{{'?redirect='+redirect if redirect else ''}}" class="font-weight-bold toggle-login">Sign up</a>
Don't have an account? <a href="/signup{{'?redirect='+redirect if redirect else ''}}" class="font-weight-bold toggle-login">Sign up</a>
</div>
</form>
</div>

View File

@ -113,10 +113,9 @@
<button class="btn btn-primary login w-100 mt-3" id="register_button">Register</button>
<div class="text-center text-muted text-small mt-2 mb-0">
Already have an account? <a href="/login{{'?redirect='+redirect if redirect else ''}}" class="font-weight-bold toggle-login">Log in</a>
<div class="text-center text-muted text-small mt-5 mb-3">
Already have an account? <a href="/login{{'?redirect='+redirect if redirect else ''}}" class="font-weight-bold toggle-login">Log in</a>
</div>
</form>
</div>

View File

@ -60,11 +60,9 @@
<label>Referral code</label>
<input autocomplete="off" type="text" class="form-control copy-link" readonly value="{{SITE_FULL}}/signup?ref={{request.values.get('ref')}}" data-clipboard-text="{{SITE_FULL}}/signup?ref={{request.values.get('ref')}}">
<div class="text-center mt-5 mb-3">
Already have an account? <a href="/login" class="font-weight-bold text-small toggle-login">Log in.</a>
</div>
<div class="text-center text-muted text-small mt-5 mb-3">
Already have an account? <a href="/login{{'?redirect='+redirect if redirect else ''}}" class="font-weight-bold toggle-login">Log in</a>
</div>
</div>
</div>