mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 22:44:24 +01:00
Add setting to allow MLC registration only (#1259)
* Adds a setting to registration visibility to allow for MLC registration while registration is disabled
This commit is contained in:
@@ -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 user as current_user
|
||||||
from CTFd.utils import validators
|
from CTFd.utils import validators
|
||||||
from CTFd.utils.config import is_teams_mode
|
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.config.visibility import registration_visible
|
||||||
from CTFd.utils.crypto import verify_password
|
from CTFd.utils.crypto import verify_password
|
||||||
from CTFd.utils.decorators import ratelimit
|
from CTFd.utils.decorators import ratelimit
|
||||||
@@ -384,7 +385,7 @@ def oauth_redirect():
|
|||||||
user = Users.query.filter_by(email=user_email).first()
|
user = Users.query.filter_by(email=user_email).first()
|
||||||
if user is None:
|
if user is None:
|
||||||
# Check if we are allowing registration before creating users
|
# Check if we are allowing registration before creating users
|
||||||
if registration_visible():
|
if registration_visible() or mlc_registration():
|
||||||
user = Users(
|
user = Users(
|
||||||
name=user_name,
|
name=user_name,
|
||||||
email=user_email,
|
email=user_email,
|
||||||
|
|||||||
@@ -83,6 +83,9 @@
|
|||||||
<option value="private" {% if registration_visibility == 'private' %}selected{% endif %}>
|
<option value="private" {% if registration_visibility == 'private' %}selected{% endif %}>
|
||||||
Private
|
Private
|
||||||
</option>
|
</option>
|
||||||
|
<option value="mlc" {% if registration_visibility == 'mlc' %}selected{% endif %}>
|
||||||
|
MajorLeagueCyber Only
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -3,3 +3,8 @@ from CTFd.utils import get_config
|
|||||||
|
|
||||||
def mlc():
|
def mlc():
|
||||||
return get_config("oauth_client_id") and get_config("oauth_client_secret")
|
return get_config("oauth_client_id") and get_config("oauth_client_secret")
|
||||||
|
|
||||||
|
|
||||||
|
def mlc_registration():
|
||||||
|
v = get_config("registration_visibility")
|
||||||
|
return v == "mlc"
|
||||||
|
|||||||
@@ -40,3 +40,5 @@ def registration_visible():
|
|||||||
return True
|
return True
|
||||||
elif v == "private":
|
elif v == "private":
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user