diff --git a/cms/settings.py b/cms/settings.py index 0e42a98..8a0410c 100644 --- a/cms/settings.py +++ b/cms/settings.py @@ -130,6 +130,10 @@ USERS_CAN_SELF_REGISTER = True RESTRICTED_DOMAINS_FOR_USER_REGISTRATION = ["xxx.com", "emaildomainwhatever.com"] +# Comma separated list of domains: ["organization.com", "private.organization.com", "org2.com"] +# Empty list disables. +ALLOWED_DOMAINS_FOR_USER_REGISTRATION = [] + # django rest settings REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": ( diff --git a/docs/admins_docs.md b/docs/admins_docs.md index f32ef86..2495f8a 100644 --- a/docs/admins_docs.md +++ b/docs/admins_docs.md @@ -355,13 +355,22 @@ ADMIN_EMAIL_LIST = ['info@mediacms.io'] ### 5.13 Disallow user registrations from specific domains -set domains that are not valid for registration via this variable: +Set domains that are not valid for registration via this variable: ``` RESTRICTED_DOMAINS_FOR_USER_REGISTRATION = [ 'xxx.com', 'emaildomainwhatever.com'] ``` +Alternatively, allow only permitted domains to register. This can be useful if you're using mediacms as a private service within an organization, and want to give free registration for those in the org, but deny registration from all other domains. Setting this option bans all domains NOT in the list from registering. Default is a blank list, which is ignored. To disable, set to a blank list. +``` +ALLOWED_DOMAINS_FOR_USER_REGISTRATION = [ + "private.com", + "vod.private.com", + "my.favorite.domain", + "test.private.com"] +``` + ### 5.14 Require a review by MediaCMS editors/managers/admins set value @@ -842,7 +851,6 @@ After this command is run, translate the string to the language you want. If the ### 20.5 Add a new language and translate To add a new language: add the language in settings.py, then add the file in `files/frontend-translations/`. Make sure you copy the initial strings by copying `files/frontend-translations/en.py` to it. - ## 21. How to change the video frames on videos By default while watching a video you can hover and see the small images named sprites that are extracted every 10 seconds of a video. You can change this number to something smaller by performing the following: diff --git a/users/adapter.py b/users/adapter.py index 8305feb..b3cc9e0 100644 --- a/users/adapter.py +++ b/users/adapter.py @@ -10,6 +10,10 @@ class MyAccountAdapter(DefaultAccountAdapter): return settings.SSL_FRONTEND_HOST + url def clean_email(self, email): + if hasattr(settings,"ALLOWED_DOMAINS_FOR_USER_REGISTRATION") and settings.ALLOWED_DOMAINS_FOR_USER_REGISTRATION: + if email.split("@")[1] not in settings.ALLOWED_DOMAINS_FOR_USER_REGISTRATION: + raise ValidationError("Domain is not in the permitted list") + if email.split("@")[1] in settings.RESTRICTED_DOMAINS_FOR_USER_REGISTRATION: raise ValidationError("Domain is restricted from registering") return email