clarkwinkelmann / flarum-ext-external-email-validation
Validate email with a call to an external API
Installs: 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Type:flarum-extension
Requires
- ext-json: *
- flarum/core: ^1.0
- guzzlehttp/guzzle: ^6.0||^7.0
Requires (Dev)
- flarum/testing: ^1.0
README
This extension adds a rule to Flarum email validation that will use an external API request to validate the email.
This rule will apply everywhere an email is checked against the UserValidator
including registration and email change requests.
The format of the external API request can be customized to meet a range of needs.
The data is expected to be passed in one of two ways: via query string, or via HTTP body.
The response can be read in one of two ways: a JSON key in the response, or the HTTP status code.
Additionally, an error message can optionally be read from a JSON key in the response. Otherwise, a default error message can be provided in the extension settings.
To inject the email value inside the URI or Body settings, use one of the following strings in the template:
{{ email | urlencode }}
: This value will be replaced with the email value passed through PHP'surlencode()
method{{ email | json }}
: This value will be replaced with the email value passed through PHP'sjson_encode()
. This means the JSON string delimiters will be included!{{ email | raw }}
: This value will be replaced with the email value without any modification. Don't use this in the URI or JSON payload if you don't know what you're doing.
Installation
composer require clarkwinkelmann/flarum-ext-external-email-validation
Support
This extension is under minimal maintenance.
It was developed for a client and released as open-source for the benefit of the community. I might publish simple bugfixes or compatibility updates for free.
You can contact me to sponsor additional features or updates.
Support is offered on a "best effort" basis through the Flarum community thread.
Integration tests
This extension has integration tests that rely on a local webserver running.
Run composer test:server
to start the PHP development server on port 8000 with the docroot set to the fixtures
folder.
Then you can run composer test:setup
and composer test
like regular Flarum integration tests.