uhh
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
<form action="/signup" method="post">
|
||||
<input type="text" id="username" name="username" class="form-control" placeholder="Username" value="" required>
|
||||
<input type="password" name="password" id="password" class="form-control" placeholder="Password" value="" required>
|
||||
{% if InviteKeysEnabled %}
|
||||
<input type="text" id="invite-key" name="invite-key" class="form-control mb-2" placeholder="Invite Key" value="" required>
|
||||
{% endif %}
|
||||
<div id="checkboxTerms">
|
||||
<input class="form-check-input" name="agreetoTermsandPrivacy" type="checkbox" id="agreeCheckbox" required>
|
||||
<label class="form-check-label" for="agreeCheckbox">
|
||||
|
||||
+24
-19
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user