1000 search results

109 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 20
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
// ... lines 22 - 23
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 26 - 107
}
See Code Block in Script
115 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 24
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 27 - 40
public function authenticate(Request $request)
{
// TODO: Implement authenticate() method.
}
// ... lines 45 - 113
}
See Code Block in Script
116 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 25
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 28 - 35
public function supports(Request $request): bool
{
// ... lines 38 - 39
}
// ... lines 41 - 114
}
See Code Block in Script
116 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 25
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 28 - 90
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): Response
{
// ... lines 93 - 97
}
// ... lines 99 - 114
}
See Code Block in Script
116 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 25
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 28 - 99
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
{
// ... lines 102 - 108
}
// ... lines 110 - 114
}
See Code Block in Script
116 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 25
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 28 - 110
protected function getLoginUrl(Request $request): string
{
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
}
}
See Code Block in Script
116 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 25
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 28 - 35
public function supports(Request $request): bool
{
return self::LOGIN_ROUTE === $request->attributes->get('_route')
&& $request->isMethod('POST');
}
// ... lines 41 - 114
}
See Code Block in Script
47 lines | src/Security/Voter/QuestionVoter.php
// ... lines 1 - 11
class QuestionVoter extends Voter
{
// ... lines 14 - 24
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
// ... lines 27 - 40
return match ($attribute) {
'EDIT' => $user === $subject->getOwner(),
default => false,
};
}
}
See Code Block in Script
121 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 11
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
// ... lines 13 - 24
class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface
{
// ... lines 27 - 36
public function __construct(SessionInterface $session, EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder)
{
// ... lines 39 - 43
}
// ... lines 45 - 119
}
See Code Block in Script
121 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 24
class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface
{
// ... lines 27 - 34
private $passwordEncoder;
// ... line 36
public function __construct(SessionInterface $session, EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, \Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface $passwordEncoder)
{
// ... lines 39 - 42
$this->passwordEncoder = $passwordEncoder;
}
// ... lines 45 - 119
}
See Code Block in Script
85 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 21
class LoginFormAuthenticator extends AbstractAuthenticator
{
// ... lines 24 - 37
public function authenticate(Request $request): PassportInterface
{
// ... lines 40 - 42
return new Passport(
new UserBadge($email, function($userIdentifier) {
// optionally pass a callback to load the User manually
$user = $this->userRepository->findOneBy(['email' => $userIdentifier]);
if (!$user) {
throw new UserNotFoundException();
}
return $user;
}),
// ... line 54
);
}
// ... lines 57 - 83
}
See Code Block in Script
85 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 21
class LoginFormAuthenticator extends AbstractAuthenticator
{
// ... lines 24 - 37
public function authenticate(Request $request): PassportInterface
{
// ... lines 40 - 42
return new Passport(
// ... lines 44 - 53
new PasswordCredentials($password)
);
}
// ... lines 57 - 83
}
See Code Block in Script
39 lines | templates/security/login.html.twig
// ... lines 1 - 4
{% block body %}
<div class="container">
<div class="row">
<div class="login-form bg-light mt-4 p-4">
<form method="post" class="row g-3">
// ... lines 10 - 24
<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
// ... lines 28 - 33
</form>
</div>
</div>
</div>
{% endblock %}
See Code Block in Script
92 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 15
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
// ... lines 17 - 22
class LoginFormAuthenticator extends AbstractAuthenticator
{
// ... lines 25 - 38
public function authenticate(Request $request): PassportInterface
{
// ... lines 41 - 43
return new Passport(
// ... lines 45 - 55
[
new CsrfTokenBadge(
// ... lines 58 - 59
)
]
);
}
// ... lines 64 - 90
}
See Code Block in Script
92 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 22
class LoginFormAuthenticator extends AbstractAuthenticator
{
// ... lines 25 - 38
public function authenticate(Request $request): PassportInterface
{
// ... lines 41 - 43
return new Passport(
// ... lines 45 - 55
[
new CsrfTokenBadge(
'authenticate',
// ... line 59
)
]
);
}
// ... lines 64 - 90
}
See Code Block in Script
92 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 22
class LoginFormAuthenticator extends AbstractAuthenticator
{
// ... lines 25 - 38
public function authenticate(Request $request): PassportInterface
{
// ... lines 41 - 43
return new Passport(
// ... lines 45 - 55
[
new CsrfTokenBadge(
'authenticate',
$request->request->get('_csrf_token')
)
]
);
}
// ... lines 64 - 90
}
See Code Block in Script
83 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 26
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 29 - 39
public function authenticate(Request $request): PassportInterface
{
$email = $request->request->get('email');
$password = $request->request->get('password');
return new Passport(
new UserBadge($email, function($userIdentifier) {
// optionally pass a callback to load the User manually
$user = $this->userRepository->findOneBy(['email' => $userIdentifier]);
if (!$user) {
throw new UserNotFoundException();
}
return $user;
}),
new PasswordCredentials($password),
[
new CsrfTokenBadge(
'authenticate',
$request->request->get('_csrf_token')
),
(new RememberMeBadge())->enable(),
]
);
}
// ... lines 66 - 81
}
See Code Block in Script
42 lines | src/Security/Voter/AdminUserVoter.php
// ... lines 1 - 4
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\User\UserInterface;
class AdminUserVoter extends Voter
{
protected function supports(string $attribute, $subject): bool
{
// replace with your own logic
// https://symfony.com/doc/current/security/voters.html
return in_array($attribute, ['POST_EDIT', 'POST_VIEW'])
&& $subject instanceof \App\Entity\AdminUser;
}
// ... line 18
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
// ... lines 21 - 39
}
}
See Code Block in Script
40 lines | src/Security/Voter/AdminUserVoter.php
// ... lines 1 - 7
use Symfony\Component\Security\Core\User\UserInterface;
// ... line 9
class AdminUserVoter extends Voter
{
protected function supports(string $attribute, $subject): bool
{
// replace with your own logic
// https://symfony.com/doc/current/security/voters.html
return in_array($attribute, ['ADMIN_USER_EDIT'])
&& $subject instanceof User;
}
// ... lines 19 - 38
}
See Code Block in Script
40 lines | src/Security/Voter/AdminUserVoter.php
// ... lines 1 - 19
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
{
// ... lines 22 - 26
if (!$subject instanceof User) {
throw new \LogicException('Subject is not an instance of User?');
}
// ... lines 30 - 37
}
// ... lines 39 - 40
See Code Block in Script