This commit is contained in:
copyrighttxt
2026-08-02 14:13:03 -04:00
committed by GitHub
parent 2ae91b647b
commit 9c45d7e6c8
4 changed files with 36 additions and 20 deletions
+24 -19
View File
@@ -33,7 +33,8 @@ def signup_page():
if not websiteFeatures.GetWebsiteFeature("WebSignup"):
flash("Signups are temporarily disabled")
SignupEnabled = False
return render_template("signup/signup.html", SignupEnabled=SignupEnabled)
InviteKeysEnabled = websiteFeatures.GetWebsiteFeature("InviteKeys")
return render_template("signup/signup.html", SignupEnabled=SignupEnabled, InviteKeysEnabled=InviteKeysEnabled)
def RateLimitReached(e):
flash("You are being rate limited. Please try again later.")
@@ -82,7 +83,8 @@ def signup_post():
flash("Please complete the captcha", "error")
return redirect("/signup")
if username is None or password is None or invitekey is None:
InviteKeysEnabled = websiteFeatures.GetWebsiteFeature("InviteKeys")
if username is None or password is None or (InviteKeysEnabled and invitekey is None):
flash("Please fill in all fields")
return redirect("/signup")
@@ -189,22 +191,23 @@ def signup_post():
flash("Username already taken")
return redirect("/signup")
try:
inviteKey : InviteKey = invitekeys.GetInviteKey(invitekey)
except invitekeys.InviteExceptions.InvalidInviteKey:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invalid invite key")
return redirect("/signup")
if inviteKey.used_by is not None:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invite key already used")
return redirect("/signup")
InviteKeyCreator : User = User.query.filter_by(id=inviteKey.created_by).first()
if InviteKeyCreator is not None:
if InviteKeyCreator.accountstatus != 1:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invite key creator's account is banned")
return redirect("/signup")
if InviteKeysEnabled:
try:
inviteKey : InviteKey = invitekeys.GetInviteKey(invitekey)
except invitekeys.InviteExceptions.InvalidInviteKey:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invalid invite key")
return redirect("/signup")
if inviteKey.used_by is not None:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invite key already used")
return redirect("/signup")
InviteKeyCreator : User = User.query.filter_by(id=inviteKey.created_by).first()
if InviteKeyCreator is not None:
if InviteKeyCreator.accountstatus != 1:
redislock.release_lock("UserSignupLock", UserSignupLock)
flash("Invite key creator's account is banned")
return redirect("/signup")
if not turnstile.VerifyToken(request.form.get('cf-turnstile-response')):
redislock.release_lock("UserSignupLock", UserSignupLock)
@@ -242,7 +245,9 @@ def signup_post():
userAvatar.torso_color_id = random.choice(AllowedBodyColors)
db.session.add(userAvatar)
invitekeys.UseInviteKey(invitekey, NewRegisteredUser)
if InviteKeysEnabled:
invitekeys.UseInviteKey(invitekey, NewRegisteredUser)
db.session.commit()
redislock.release_lock("UserSignupLock", UserSignupLock)