1000 search results

39 lines | src/Security/Voter/StarshipVoter.php
// ... lines 1 - 10
final class StarshipVoter extends Voter
{
// ... lines 13 - 21
/**
* @param Starship $subject
*/
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
// ... lines 26 - 37
}
See Code Block in Script
39 lines | src/Security/Voter/StarshipVoter.php
// ... lines 1 - 10
final class StarshipVoter extends Voter
{
// ... lines 13 - 24
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
{
// ... lines 27 - 35
return $subject->getId() === $user->getStarship()?->getId();
}
}
See Code Block in Script
70 lines | templates/security/login.html.twig
// ... lines 1 - 4
{% block body %}
<section class="px-6 py-10 sm:py-16">
<div class="mx-auto max-w-md">
<div class="rounded-2xl border border-white/10 bg-[#16202A]/80 p-8 shadow-2xl shadow-black/30 backdrop-blur-sm">
// ... lines 9 - 14
<form method="post" class="space-y-6">
// ... lines 16 - 56
<div class="flex items-center gap-3 rounded-lg border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80">
<input type="checkbox" checked name="_remember_me" id="_remember_me" class="rounded border-white/20 bg-transparent text-cyan-400 focus:ring-cyan-400">
<label for="_remember_me">Remember me</label>
</div>
// ... lines 61 - 64
</form>
</div>
</div>
</section>
{% endblock %}
See Code Block in Script
62 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 18
final class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 21 - 44
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
if ($targetPath = $request->query->get('_target_path')) {
return new RedirectResponse($targetPath);
}
// ... lines 50 - 54
}
// ... lines 56 - 60
}
See Code Block in Script
16 lines | templates/security/enable2fa.html.twig
{% extends 'base.html.twig' %}
{% block title %}2fa Activation{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="login-form bg-light mt-4 p-4">
<h1 class="h3 mb-3 font-weight-normal">Use Authy or Google Authenticator to Scan the QR Code</h1>
// ... lines 10 - 11
</div>
</div>
</div>
{% endblock %}
See Code Block in Script
{% extends 'base.html.twig' %}
{% block title %}2fa Activation{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="login-form bg-light mt-4 p-4">
<h1 class="h3 mb-3 font-weight-normal">Use Authy or Google Authenticator to Scan the QR Code</h1>
<img src="{{ path('app_qr_code') }}" alt="2fa QR Code">
</div>
</div>
</div>
{% endblock %}
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 26
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
// ... lines 28 - 29
class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
{
// ... lines 32 - 39
public function authenticate(Request $request): Passport
{
// ... lines 42 - 66
}
// ... lines 68 - 136
}
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 39
public function authenticate(Request $request): Passport
{
$email = $request->request->get('email');
$password = $request->request->get('password');
return new Passport(
// ... lines 46 - 65
);
}
// ... lines 68 - 138
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 39
public function authenticate(Request $request): Passport
{
// ... lines 42 - 44
return new Passport(
new UserBadge($email, function($userIdentifier) {
// optionally pass a callback to load the User manually
$user = $this->entityManager
->getRepository(User::class)
->findOneBy(['email' => $userIdentifier]);
if (!$user) {
throw new UserNotFoundException();
}
return $user;
}),
// ... lines 58 - 65
);
}
// ... lines 68 - 138
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 39
public function authenticate(Request $request): Passport
{
// ... lines 42 - 44
return new Passport(
new UserBadge($email, function($userIdentifier) {
// ... lines 47 - 56
}),
new PasswordCredentials($password),
// ... lines 59 - 65
);
}
// ... lines 68 - 138
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 39
public function authenticate(Request $request): Passport
{
// ... lines 42 - 44
return new Passport(
// ... lines 46 - 57
new PasswordCredentials($password),
[
new CsrfTokenBadge(
'authenticate',
$request->request->get('_csrf_token')
),
// ... line 64
]
);
}
// ... lines 68 - 138
See Code Block in Script
138 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 39
public function authenticate(Request $request): Passport
{
// ... lines 42 - 44
return new Passport(
// ... lines 46 - 57
new PasswordCredentials($password),
[
// ... lines 60 - 63
(new RememberMeBadge())->enable(),
]
);
}
// ... lines 68 - 138
See Code Block in Script
87 lines | src/Security/LoginFormAuthenticator.php
// ... lines 1 - 28
public function __construct(private SessionInterface $session, private EntityManagerInterface $entityManager, private UrlGeneratorInterface $urlGenerator)
{
}
// ... lines 32 - 87
See Code Block in Script
45 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 8
class DragonTreasureVoter extends Voter
{
// ... lines 11 - 13
protected function supports(string $attribute, mixed $subject): bool
{
// ... lines 16 - 19
}
// ... lines 21 - 43
}
See Code Block in Script
40 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 9
class DragonTreasureVoter extends Voter
{
public const EDIT = 'EDIT';
protected function supports(string $attribute, mixed $subject): bool
{
return in_array($attribute, [self::EDIT])
&& $subject instanceof DragonTreasure;
}
// ... lines 19 - 38
}
See Code Block in Script
40 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 9
class DragonTreasureVoter extends Voter
{
// ... lines 12 - 19
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
return false;
// ... lines 23 - 37
}
}
See Code Block in Script
40 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 9
class DragonTreasureVoter extends Voter
{
// ... lines 12 - 19
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
return false;
$user = $token->getUser();
// if the user is anonymous, do not grant access
if (!$user instanceof UserInterface) {
return false;
}
// ... (check conditions and return true to grant permission) ...
switch ($attribute) {
case self::EDIT:
// logic to determine if the user can EDIT
// return true or false
break;
}
return false;
}
}
See Code Block in Script
43 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 9
class DragonTreasureVoter extends Voter
{
// ... lines 12 - 19
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
$user = $token->getUser();
// if the user is anonymous, do not grant access
if (!$user instanceof UserInterface) {
return false;
}
assert($subject instanceof DragonTreasure);
// ... (check conditions and return true to grant permission) ...
// ... lines 31 - 40
}
}
See Code Block in Script
43 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 9
class DragonTreasureVoter extends Voter
{
// ... lines 12 - 19
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
{
// ... lines 22 - 29
// ... (check conditions and return true to grant permission) ...
switch ($attribute) {
case self::EDIT:
if ($subject->getOwner() === $user) {
return true;
}
break;
}
return false;
}
}
See Code Block in Script
52 lines | src/Security/Voter/DragonTreasureVoter.php
// ... lines 1 - 5
use Symfony\Bundle\SecurityBundle\Security;
// ... lines 7 - 10
class DragonTreasureVoter extends Voter
{
// ... lines 13 - 14
public function __construct(private Security $security)
{
}
// ... lines 18 - 50
}
See Code Block in Script