Assuming you are using misago_docker
, you should create directory named emailrestriction
in the misago
directory (same directory that contains manage.py
file).
Inside this directory you will need to create two files:
__init__.py
default_app_config = "emailrestriction.apps.EmailRestrictionPluginConfig"
apps.py
:
from django.apps import AppConfig
from misago.hooks import new_registrations_validators
class EmailRestrictionPluginConfig(AppConfig):
name = "emailrestriction"
label = "emailrestriction"
verbose_name = "Email Restriction"
def ready(self):
new_registrations_validators.append(custom_email_validator)
def custom_email_validator(request, cleaned_data, add_error):
email = cleaned_data.get("email")
if not email:
return
if not email.lower().endswith("@mydomain.com"):
add_error(
"email", "You need to use an e-mail from mydomain.com to join this site."
)
Replace mydomain.com
part with your own domain.
Now, create file named plugins.txt
in same directory that you've created emailrestriction
directory in (the one that has manage.py
file). Misago will use this file to read list of enabled plugins.
Inside of this file enter single line:
emailrestriction
This will make Misago load your emailrestriction
plugin that you've just created.
Lastly rebuild Misago's Docker container using appctl
:
$ appctl rebuild
That should do the trick.