diff --git a/dojo_plugin/models/__init__.py b/dojo_plugin/models/__init__.py index f95832817..c6fff1895 100644 --- a/dojo_plugin/models/__init__.py +++ b/dojo_plugin/models/__init__.py @@ -60,6 +60,7 @@ class Dojos(db.Model): description = db.Column(db.Text) official = db.Column(db.Boolean, index=True) + joinable = db.Column(db.Boolean) password = db.Column(db.String(128)) data = db.Column(db.JSON) diff --git a/dojo_plugin/pages/dojos.py b/dojo_plugin/pages/dojos.py index 47ecd09f2..469707e09 100644 --- a/dojo_plugin/pages/dojos.py +++ b/dojo_plugin/pages/dojos.py @@ -75,6 +75,9 @@ def join_dojo(dojo, password=None): if dojo.official: return redirect(url_for("pwncollege_dojo.listing", dojo=dojo.reference_id)) + if not dojo.joinable: + abort(403) + if dojo.password and dojo.password != password: abort(403) diff --git a/dojo_plugin/utils/dojo/__init__.py b/dojo_plugin/utils/dojo/__init__.py index e538e3738..2544a13e7 100644 --- a/dojo_plugin/utils/dojo/__init__.py +++ b/dojo_plugin/utils/dojo/__init__.py @@ -187,7 +187,7 @@ def assert_one(query, error_message): dojo_kwargs = { field: dojo_data.get(field, getattr(import_dojo, field, None)) - for field in ["id", "name", "description", "password", "type", "award"] + for field in ["id", "name", "description", "password", "type", "award", "joinable"] } if dojo is None: