This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1620 from ojs/feature/disposable-email
Feature/disposable email blocker on registeration
- Loading branch information
Showing
7 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Ojs/UserBundle/Validator/Constraints/DisposableEmail.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Ojs\UserBundle\Validator\Constraints; | ||
|
||
use Ojs\UserBundle\Validator\DisposableEmailValidator; | ||
use Symfony\Component\Validator\Constraints\Email; | ||
|
||
/** | ||
* @Annotation | ||
*/ | ||
class DisposableEmail extends Email | ||
{ | ||
public $message = 'One or more of emails are not available or valid domain.'; | ||
|
||
public function validatedBy() | ||
{ | ||
return DisposableEmailValidator::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
|
||
namespace Ojs\UserBundle\Validator; | ||
|
||
use ContentFarm\DisposableEmail\DisposableEmailService; | ||
use Ojs\UserBundle\Validator\Constraints\DisposableEmail; | ||
use Symfony\Component\Validator\Constraint; | ||
use Symfony\Component\Validator\ConstraintValidator; | ||
|
||
/** | ||
* @Annotation | ||
*/ | ||
class DisposableEmailValidator extends ConstraintValidator | ||
{ | ||
/** | ||
* @param mixed $value | ||
* @param Constraint|DisposableEmail $constraint | ||
* @return mixed | ||
*/ | ||
public function validate($value, Constraint $constraint) | ||
{ | ||
|
||
$disposableEmailService = new DisposableEmailService(); | ||
$disposableEmailService->mail = $value; | ||
|
||
|
||
if ($disposableEmailService->isDisposableEmail()) { | ||
$this->context->addViolation($constraint->message); | ||
} | ||
|
||
} | ||
} |