• Members 11 posts
    Nov. 27, 2019, 3:33 p.m.

    Hello,

    I am considering setting up Misago as an internal company forum to support some software. I would need to limit accounts to email addresses at our company: xxx@mycompany.com only.
    Can this be configured? If not would it be difficult to modify the soft to create this restriction?

    Thanks

    Pete

  • Nov. 27, 2019, 10:05 p.m.

    You can create plugin that requires users to enter email from specified domain, and enable "user activation" requirement in admin, so they will need to prove they own valid e-mail by clicking activation link in e-mail message sent to them.

    I don't have time to show how example plugin would look like, but I'll hopefully have something to show by end of the week.

  • Members 11 posts
    Nov. 28, 2019, 6:12 p.m.

    Super, that would be great, thanks much in advance!

  • Nov. 30, 2019, 12:37 a.m.

    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.

  • Members 11 posts
    Dec. 3, 2019, 11:16 a.m.

    Hello,

    That is fantastic!

    Thank you very much!

    Pete

  • Members 11 posts
    Feb. 5, 2020, 1:07 p.m.

    I had this installed and it works perfectly!
    Thanks