Rename to ExpireEmailValidation, because it does not automatically expire and it does not expire users

master
Lars Vierbergen 7 years ago
parent f2f431b9a6
commit e70cccd7a1
  1. 8
      AuthserverAutoExpireUsersBundle.php
  2. 8
      AuthserverExpireEmailValidationBundle.php
  3. 14
      Command/ExpireEmailValidationCommand.php
  4. 4
      DependencyInjection/AuthserverExpireEmailValidationExtension.php
  5. 2
      Entity/ExpiredUser.php
  6. 6
      EventListener/CheckExpiryListener.php
  7. 4
      EventListener/EmailAddressVerificationListener.php
  8. 19
      README.md
  9. 4
      Resources/config/services.xml
  10. 6
      Resources/migrations/VersionExpireEmailValidation20180510212258.php
  11. 4
      composer.json

@ -1,8 +0,0 @@
<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AuthserverAutoExpireUsersBundle extends Bundle
{
}

@ -0,0 +1,8 @@
<?php
namespace vierbergenlars\AuthserverExpireEmailValidationBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AuthserverExpireEmailValidationBundle extends Bundle
{
}

@ -1,5 +1,5 @@
<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\Command;
namespace vierbergenlars\AuthserverExpireEmailValidationBundle\Command;
use App\Entity\User;
use Symfony\Component\Console\Command\Command;
@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use vierbergenlars\AuthserverAutoExpireUsersBundle\Entity\ExpiredUser;
use vierbergenlars\AuthserverExpireEmailValidationBundle\Entity\ExpiredUser;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Join;
use Symfony\Component\Console\Question\Question;
@ -15,12 +15,12 @@ use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Style\SymfonyStyle;
use App\AppBundle;
class ExpireUsersCommand extends Command
class ExpireEmailValidationCommand extends Command
{
protected function configure()
{
$this->setName('expire:users')
$this->setName('expire:email-validation')
->addOption('username', null, InputOption::VALUE_REQUIRED, 'The username of the user to expire')
->addOption('last-login-before', null, InputOption::VALUE_REQUIRED, 'Users with a last login before this date will be expired')
->addOption('exclude-admins', null, InputOption::VALUE_NONE, 'Exclude admins from expiry')
@ -72,7 +72,7 @@ class ExpireUsersCommand extends Command
return 0;
}
if (!$input->getOption('dry-run') && !$style->confirm('Will expire ' . $count . ' users. Continue?', true)) {
if (!$input->getOption('dry-run') && !$style->confirm('Will expire ' . $count . ' user email validations. Continue?', true)) {
$style->error('Expiration cancelled.');
return 1;
}
@ -86,7 +86,7 @@ class ExpireUsersCommand extends Command
foreach ($usersIterator as list ($user)) {
/* @var $user \App\Entity\User */
$progressBar->clear();
$style->text('Expired user ' . $user->getUsername());
$style->text('Expired email validations of user ' . $user->getUsername());
$progressBar->display();
$progressBar->advance();
$progressBar->setMessage($user->getUsername());
@ -103,6 +103,6 @@ class ExpireUsersCommand extends Command
$progressBar->finish();
$style->success('Expired ' . $count . ' users');
$style->success('Expired ' . $count . ' user email validations');
}
}

@ -17,14 +17,14 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\DependencyInjection;
namespace vierbergenlars\AuthserverExpireEmailValidationBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class AuthserverAutoExpireUsersExtension extends Extension
class AuthserverExpireEmailValidationExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)

@ -1,5 +1,5 @@
<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\Entity;
namespace vierbergenlars\AuthserverExpireEmailValidationBundle\Entity;
use App\Entity\User;
use Doctrine\ORM\Mapping\Entity;

@ -1,5 +1,5 @@
<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\EventListener;
namespace vierbergenlars\AuthserverExpireEmailValidationBundle\EventListener;
use App\AppEvents;
use App\Event\UserCheckerEvent;
@ -10,7 +10,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationEvent;
use vierbergenlars\AuthserverAutoExpireUsersBundle\Entity\ExpiredUser;
use vierbergenlars\AuthserverExpireEmailValidationBundle\Entity\ExpiredUser;
use vierbergenlars\AuthserverStatsBundle\Event\StatsEvent;
use Symfony\Component\VarDumper\VarDumper;
use Psr\Log\LoggerInterface;
@ -119,7 +119,7 @@ class CheckExpiryListener implements EventSubscriberInterface
}
}
$this->em->flush();
throw new AccountExpiredException('Account has expired.');
throw new AccountExpiredException('Email address verification expired. An email has been sent to your email addresses to reactivate your account.');
}
}

@ -1,5 +1,5 @@
<?php
namespace vierbergenlars\AuthserverAutoExpireUsersBundle\EventListener;
namespace vierbergenlars\AuthserverExpireEmailValidationBundle\EventListener;
use App\AppEvents;
use App\Event\UserCheckerEvent;
@ -11,7 +11,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\AuthenticationEvents;
use Symfony\Component\Security\Core\Event\AuthenticationEvent;
use vierbergenlars\AuthserverAutoExpireUsersBundle\Entity\ExpiredUser;
use vierbergenlars\AuthserverExpireEmailValidationBundle\Entity\ExpiredUser;
use vierbergenlars\AuthserverStatsBundle\Event\StatsEvent;
use Symfony\Component\VarDumper\VarDumper;
use Psr\Log\LoggerInterface;

@ -0,0 +1,19 @@
# Authserver: Expire email address validation plugin
This [Authserver](https://github.com/vierbergenlars/authserver) plugin that allows to expire email address validations of users.
## Installation
`./plugin.sh install vierbergenlars/authserver-expire-email-validation-bundle`
For more details, see the [Authserver plugin documentation](https://github.com/vierbergenlars/authserver/blob/master/documentation/plugins.md).
## Usage
This plugin does not require any configuration to use it. When no validations have been expired, it does not have any effect.
Users can be expired with the `php app/console expire:email-validation` command.
When a user tries to log in after their email address validations have been expired, the login is blocked.
They are notified that their email validations have expired and that a new validation email has been sent to all existing, previously validated email addresses.
They have to re-validate at least one of their existing email addresses to regain access to their account.

@ -3,14 +3,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service class="vierbergenlars\AuthserverAutoExpireUsersBundle\EventListener\CheckExpiryListener">
<service class="vierbergenlars\AuthserverExpireEmailValidationBundle\EventListener\CheckExpiryListener">
<argument type="service" id="doctrine.orm.entity_manager" />
<argument type="service" id="app.mailer.user.verify_email" />
<argument type="service" id="logger" />
<tag name="kernel.event_subscriber" />
<tag name="monolog.logger" channel="security" />
</service>
<service class="vierbergenlars\AuthserverAutoExpireUsersBundle\EventListener\EmailAddressVerificationListener">
<service class="vierbergenlars\AuthserverExpireEmailValidationBundle\EventListener\EmailAddressVerificationListener">
<argument type="service" id="logger" />
<tag name="doctrine.event_subscriber" />
</service>

@ -4,12 +4,12 @@ namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class VersionAutoExpireUsers20180510212258 extends AbstractMigration
class VersionExpireEmailValidation20180510212258 extends AbstractMigration
{
public function up(Schema $schema)
{
$expires = $schema->createTable('vierbergenlars_expire_users');
$expires = $schema->createTable('vierbergenlars_expire_email_validation');
$expires->addColumn('user_id', 'integer');
@ -29,6 +29,6 @@ class VersionAutoExpireUsers20180510212258 extends AbstractMigration
public function down(Schema $schema)
{
$schema->dropTable('vierbergenlars_expire_users');
$schema->dropTable('vierbergenlars_expire_email_validation');
}
}

@ -1,5 +1,5 @@
{
"name" : "vierbergenlars/authserver-autoexpire-users-bundle",
"name" : "vierbergenlars/authserver-expire-email-validation-bundle",
"type" : "authserver-plugin",
"license" : "AGPL",
"authors" : [{
@ -9,7 +9,7 @@
],
"autoload" : {
"psr-4" : {
"vierbergenlars\\AuthserverAutoExpireUsersBundle\\" : "."
"vierbergenlars\\AuthserverExpireEmailValidationBundle\\" : "."
}
},
"config" : {