Plugin: Allowed Registration Email Patterns

Hi,
I want to allow specific emails for registration. I tried to write a plugin following opnedx documentation. Now, When I list the plugin, it shows on the list. When I enable the plugin, it successfully enabled. After enabling the plugin, tutor config save works but tutor local quickstart gives some error and tutor failed to start.
The plugin:

name: allowmail
version: 0.1
patches:
  common-env-features: |
    "REGISTRATION_EMAIL_PATTERNS_ALLOWED" = [
   "^.*@(.*\\.)?example\\.com$",
   "(^\\w+\\.\\w+)@school\\.tld$"
   ]

tutor local quickstart error:

       Traceback (most recent call last):
       File "./manage.py", line 119, in <module>
       startup = importlib.import_module(edx_args.startup)
       File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
       __import__(name)
      File "/openedx/edx-platform/lms/startup.py", line 9, in <module>
      settings.INSTALLED_APPS  # pylint: disable=pointless-statement
      File "/openedx/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
      self._setup(name)
      File "/openedx/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
      self._wrapped = Settings(settings_module)
      File "/openedx/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
      mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
      __import__(name)
      File "/openedx/edx-platform/lms/envs/tutor/production.py", line 3, in <module>
      from lms.envs.production import *
      File "/openedx/edx-platform/lms/envs/production.py", line 108, in <module>
      ENV_TOKENS = json.load(env_file)
      File "/usr/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
      File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
      return _default_decoder.decode(s)
      File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
      obj, end = self.scan_once(s, idx)
      ValueError: Expecting : delimiter: line 9 column 43 (char 264)

Can anyone help me solve this problem?
Thanks

You are patching a json file. Thus, the X = "value" syntax is incorrect. You should have instead X: "value". Hence the syntax error you are facing. The correct syntax should probably be:

name: allowmail
version: 0.1
patches:
  common-env-features: |
    "REGISTRATION_EMAIL_PATTERNS_ALLOWED": [
   "^.*@(.*\\.)?example\\.com$",
   "(^\\w+\\.\\w+)@school\\.tld$"
   ]
1 Like

Thanks for your reply. I figured it out last night. But I replaced openedx-common-settings with common-env-features.