feat: add 'remember me' functionality
This commit is contained in:
@@ -26,6 +26,11 @@ security:
|
||||
logout:
|
||||
path: app_security_logout
|
||||
target: app_security_login
|
||||
remember_me:
|
||||
secret: '%kernel.secret%'
|
||||
lifetime: 604800
|
||||
token_provider:
|
||||
doctrine: true
|
||||
access_control:
|
||||
- { path: '^/', roles: PUBLIC_ACCESS, requires_channel: https }
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241030091854 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE rememberme_token (series VARCHAR(88) NOT NULL, value VARCHAR(88) NOT NULL, lastUsed DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', class VARCHAR(100) NOT NULL, username VARCHAR(200) NOT NULL, PRIMARY KEY(series)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE rememberme_token');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
||||
@@ -73,7 +74,10 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
|
||||
|
||||
return $user;
|
||||
}),
|
||||
[new CsrfTokenBadge('authenticate', $csrfToken)]
|
||||
[
|
||||
new CsrfTokenBadge('authenticate', $csrfToken),
|
||||
new RememberMeBadge(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
required
|
||||
autocomplete="current-password">
|
||||
</div>
|
||||
<div class="flex items-start mb-6">
|
||||
<label for="rememberme" class="flex h-6 items-center">
|
||||
<input type="checkbox" id="rememberme" name="_remember_me" class="h-4 w-4 rounded text-primary">
|
||||
<span class="block ml-3 leading-6">
|
||||
angemeldet bleiben
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit" class="btn w-full">
|
||||
Login
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user