-
-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set option for allowing only certain domains to register #1086
Conversation
yatesdr
commented
Oct 18, 2024
•
edited
Loading
edited
- Create a key ALLOWED_DOMAINS_FOR_USER_REGISTRATION, default as an empty list in settings.py
- Apply the key in the E-mail registration validation function to supersede the RESTRICTED_DOMAINS.... setting only if there are items in the new list.
Add an optional ALLOWED_DOMAINS_FOR_USER_REGISTRATION key.
users/adapter.py
Outdated
@@ -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 len(settings.ALLOWED_DOMAINS_FOR_USER_REGISTRATION): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to query for this more defensively, eg like this
if hasattr(settings, "ALLOWED_DOMAINS_FOR_USER_REGISTRATION") ...
this ensures that settings
won't break with an AttributeError
in case it's missing in settings.py
Also no need to check with len() explicitly, the same can be through:
if hasattr(settings, "ALLOWED_DOMAINS_FOR_USER_REGISTRATION") and settings.ALLOWED_DOMAINS_FOR_USER_REGISTRATION:
Great, I made some minor suggestions, if you can check them. Also can you add a small entry in https://github.com/mediacms-io/mediacms/blob/main/docs/admins_docs.md ? This doc is not a good way of keeping documentation but it's better than nothing :) |
Defensively check for attribute before querying.
Short documentation for ALLOWED_DOMAINS_FOR_USER_REGISTRATION addition.
Good feedback, all complete now. |
Merged, thanks for the PR, feel free to contribute to other parts too :) |
Happy to contribute, there's a couple other minor features I'm examining, but not sure if they'd be of use or if I have the skillset to properly implement them. My current use-case is as a back-end media manager to Canvas, an online learning platform, to host videos that are often not licensed to be shared publicly. To facilitate this use-case, the two main features I'm looking into are:
Thanks again! D |