Skip to content

Commit

Permalink
feat: Set option for allowing only certain domains to register (#1086)
Browse files Browse the repository at this point in the history
yatesdr authored Oct 19, 2024
1 parent aa8a2d9 commit 673ddeb
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cms/settings.py
Original file line number Diff line number Diff line change
@@ -130,6 +130,10 @@

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": (
12 changes: 10 additions & 2 deletions docs/admins_docs.md
Original file line number Diff line number Diff line change
@@ -355,13 +355,22 @@ ADMIN_EMAIL_LIST = ['[email protected]']

### 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:
4 changes: 4 additions & 0 deletions users/adapter.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@ def get_email_confirmation_url_stub(self, request, emailconfirmation):
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

0 comments on commit 673ddeb

Please sign in to comment.