Add setting to allow MLC registration only (#1259)

* Adds a setting to registration visibility to allow for MLC registration while registration is disabled
bulk-clear-sessions
Kevin Chung 2020-02-23 23:33:34 -05:00 committed by GitHub
parent 0bae69bee4
commit 7ee47b0abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,7 @@ from CTFd.utils import config, email, get_app_config, get_config
from CTFd.utils import user as current_user
from CTFd.utils import validators
from CTFd.utils.config import is_teams_mode
from CTFd.utils.config.integrations import mlc_registration
from CTFd.utils.config.visibility import registration_visible
from CTFd.utils.crypto import verify_password
from CTFd.utils.decorators import ratelimit
@ -384,7 +385,7 @@ def oauth_redirect():
user = Users.query.filter_by(email=user_email).first()
if user is None:
# Check if we are allowing registration before creating users
if registration_visible():
if registration_visible() or mlc_registration():
user = Users(
name=user_name,
email=user_email,

View File

@ -83,6 +83,9 @@
<option value="private" {% if registration_visibility == 'private' %}selected{% endif %}>
Private
</option>
<option value="mlc" {% if registration_visibility == 'mlc' %}selected{% endif %}>
MajorLeagueCyber Only
</option>
</select>
</div>

View File

@ -3,3 +3,8 @@ from CTFd.utils import get_config
def mlc():
return get_config("oauth_client_id") and get_config("oauth_client_secret")
def mlc_registration():
v = get_config("registration_visibility")
return v == "mlc"

View File

@ -40,3 +40,5 @@ def registration_visible():
return True
elif v == "private":
return False
else:
return False