From 25ed99f9ef6b52a5112ab0d0dff8a9b26e2e27fa Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 20 Sep 2016 16:45:00 -0400 Subject: [PATCH] Add feature flag to turn off requirement for team invitations Fixes #1804 --- config.py | 3 +++ endpoints/api/team.py | 3 ++- static/directives/config/config-setup-tool.html | 12 ++++++++++++ util/config/configutil.py | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index e0ae3f8fb..957c03c93 100644 --- a/config.py +++ b/config.py @@ -208,6 +208,9 @@ class DefaultConfig(object): # Docker. FEATURE_LIBRARY_SUPPORT = True + # Feature Flag: Whether to require invitations when adding a user to a team. + FEATURE_REQUIRE_TEAM_INVITE = True + # The namespace to use for library repositories. # Note: This must remain 'library' until Docker removes their hard-coded namespace for libraries. # See: https://github.com/docker/docker/blob/master/registry/session.go#L320 diff --git a/endpoints/api/team.py b/endpoints/api/team.py index 358887af1..361337b84 100644 --- a/endpoints/api/team.py +++ b/endpoints/api/team.py @@ -41,8 +41,9 @@ def try_accept_invite(code, user): def handle_addinvite_team(inviter, team, user=None, email=None): + requires_invite = features.MAILING and features.REQUIRE_TEAM_INVITE invite = model.team.add_or_invite_to_team(inviter, team, user, email, - requires_invite=features.MAILING) + requires_invite=requires_invite) if not invite: # User was added to the team directly. return diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index 9afaf4a23..b0d574f32 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -74,6 +74,18 @@ + + Team Invitations: + +
+ Require Team Invitations +
+
+ If enabled, when adding a new user to a team, they will receive an invitation to join the team, with the option to decline. + Otherwise, users will be immediately part of a team when added by a team administrator. +
+ + diff --git a/util/config/configutil.py b/util/config/configutil.py index aa088f7ae..f54574193 100644 --- a/util/config/configutil.py +++ b/util/config/configutil.py @@ -15,6 +15,7 @@ def add_enterprise_config_defaults(config_obj, current_secret_key, hostname): config_obj['FEATURE_USER_LOG_ACCESS'] = config_obj.get('FEATURE_USER_LOG_ACCESS', True) config_obj['FEATURE_USER_CREATION'] = config_obj.get('FEATURE_USER_CREATION', True) config_obj['FEATURE_ANONYMOUS_ACCESS'] = config_obj.get('FEATURE_ANONYMOUS_ACCESS', True) + config_obj['FEATURE_REQUIRE_TEAM_INVITE'] = config_obj.get('FEATURE_REQUIRE_TEAM_INVITE', True) # Default features that are off. config_obj['FEATURE_MAILING'] = config_obj.get('FEATURE_MAILING', False)