{"record":{"id":"6f9b150f51179305","repo":"makeplane/plane","slug":"5016","errorCode":"5016","errorMessage":"MAGIC_LINK_LOGIN_DISABLED","messagePattern":"MAGIC_LINK_LOGIN_DISABLED","errorType":"exception","errorClass":"AuthenticationException","httpStatus":null,"severity":"error","filePath":"apps/api/plane/authentication/provider/credentials/magic_code.py","lineNumber":65,"sourceCode":"        (EMAIL_HOST, ENABLE_MAGIC_LINK_LOGIN) = get_configuration_value(\n            [\n                {\"key\": \"EMAIL_HOST\", \"default\": os.environ.get(\"EMAIL_HOST\")},\n                {\n                    \"key\": \"ENABLE_MAGIC_LINK_LOGIN\",\n                    \"default\": os.environ.get(\"ENABLE_MAGIC_LINK_LOGIN\", \"1\"),\n                },\n            ]\n        )\n\n        if not (EMAIL_HOST):\n            raise AuthenticationException(\n                error_code=AUTHENTICATION_ERROR_CODES[\"SMTP_NOT_CONFIGURED\"],\n                error_message=\"SMTP_NOT_CONFIGURED\",\n                payload={\"email\": str(key)},\n            )\n\n        if ENABLE_MAGIC_LINK_LOGIN == \"0\":\n            raise AuthenticationException(\n                error_code=AUTHENTICATION_ERROR_CODES[\"MAGIC_LINK_LOGIN_DISABLED\"],\n                error_message=\"MAGIC_LINK_LOGIN_DISABLED\",\n                payload={\"email\": str(key)},\n            )\n\n        super().__init__(request=request, provider=self.provider, callback=callback)\n        self.key = key\n        self.code = code\n\n    def initiate(self):\n        ## Generate a random token\n        token = str(secrets.randbelow(900000) + 100000)\n\n        ri = redis_instance()\n\n        key = \"magic_\" + str(self.key)\n\n        # Check if the key already exists in python","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/authentication/provider/credentials/magic_code.py#L47-L83","documentation":"Raised in MagicCodeProvider.__init__ (magic_code.py:65) when ENABLE_MAGIC_LINK_LOGIN equals \"0\". The default is \"1\" (enabled) from the env fallback, so this only fires when an operator explicitly disables magic-link login. Code 5016, payload {email}. It is checked AFTER SMTP_NOT_CONFIGURED, so EMAIL_HOST is already non-empty here.","triggerScenarios":"Constructing MagicCodeProvider resolves ENABLE_MAGIC_LINK_LOGIN (default \"1\"). If it is \"0\", AuthenticationException code 5016 is raised. Hit by calling the magic-code request/verify endpoints while the feature is disabled.","commonSituations":"Security policy mandates password/OAuth-only auth; operator set ENABLE_MAGIC_LINK_LOGIN=0 to disable magic-code; partial config migration left the flag off.","solutions":["Set ENABLE_MAGIC_LINK_LOGIN=1 (or remove the \"0\" override) if magic-code login should be available.","If disabled intentionally, update the client to offer only enabled auth methods.","Persist the flag in instance configuration, not just env, so it is consistent across instances."],"exampleFix":"# before: ENABLE_MAGIC_LINK_LOGIN=0 -> magic-code call -> 5016\n# ENABLE_MAGIC_LINK_LOGIN=1\n# after: magic-code provider constructs and issues tokens","handlingStrategy":"validation","validationCode":"from plane.license.utils.instance_value import get_configuration_value\nimport os\n\ndef magic_link_enabled() -> bool:\n    (val,) = get_configuration_value([{'key': 'ENABLE_MAGIC_LINK_LOGIN', 'default': os.environ.get('ENABLE_MAGIC_LINK_LOGIN', '1')}])\n    return val != '0'","typeGuard":null,"tryCatchPattern":"try:\n    MagicCodeProvider(request, key=email)\nexcept AuthenticationException as e:\n    if e.error_code == 5016:\n        offer_alternative_auth()\n    else:\n        raise","preventionTips":["Reflect ENABLE_MAGIC_LINK_LOGIN in the UI so users only see enabled methods.","Keep the flag in instance config for consistency."],"tags":["authentication","magic-code","configuration","feature-flag","env"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}