-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
roadiz-ci
committed
Aug 2, 2024
1 parent
1fadc51
commit 8939cf3
Showing
16 changed files
with
272 additions
and
18 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
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
38 changes: 38 additions & 0 deletions
38
src/Security/Authentication/BackofficeAuthenticationSuccessHandler.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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\CoreBundle\Security\Authentication; | ||
|
||
use Doctrine\Persistence\ManagerRegistry; | ||
use RZ\Roadiz\CoreBundle\Entity\User; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; | ||
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; | ||
|
||
final class BackofficeAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface | ||
{ | ||
public function __construct( | ||
private readonly UrlGeneratorInterface $urlGenerator, | ||
private readonly ManagerRegistry $managerRegistry | ||
) { | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function onAuthenticationSuccess(Request $request, TokenInterface $token): ?Response | ||
{ | ||
$user = $token->getUser(); | ||
|
||
if ($user instanceof User) { | ||
$user->setLastLogin(new \DateTime('now')); | ||
$manager = $this->managerRegistry->getManagerForClass(User::class); | ||
$manager?->flush(); | ||
} | ||
|
||
return new RedirectResponse($this->urlGenerator->generate('adminHomePage')); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{% extends '@RoadizCore/email/base_email.html.twig' %} | ||
|
||
{% block title %}<title>{% trans %}login_link.request{% endtrans %}</title>{% endblock %} | ||
|
||
{% block content_table %} | ||
<table width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="content-block"> | ||
{% block content_title %} | ||
<h1 itemprop="name">{% trans %}login_link.request{% endtrans %}</h1> | ||
{% endblock %} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="content-block"> | ||
<table class="invoice" itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction"> | ||
<tr> | ||
<td class="content-block"> | ||
{% block content_subtitle %} | ||
<h2>{{ 'you.asked.for.a.login_link.on.site'|trans({'%site%':site})|escape }}</h2> | ||
{% endblock %} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<p>{% trans %}click_on_following_link_to_login{% endtrans %}</p> | ||
<p>{{ 'login_link_will_expire_at.expiresAt'|trans({ | ||
'%expiresAt%': expiresAt|format_datetime('short', 'short'), | ||
}) }}</p> | ||
<p class="aligncenter" itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler"> | ||
<a class="btn-primary" href="{{ loginLink }}" itemprop="url">{% trans %}login{% endtrans %}</a> | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
{% endblock %} |
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,16 @@ | ||
{% extends '@RoadizCore/email/base_email.txt.twig' %} | ||
|
||
{% block title %}{% trans %}login_link.request{% endtrans %}{% endblock %} | ||
{% block content_subtitle %}{{ 'you.asked.for.a.login_link.on.site'|trans({'%site%':site})|escape }}{% endblock %} | ||
|
||
{% block content_table %} | ||
{% trans %}click_on_following_link_to_login{% endtrans %} | ||
{{ 'login_link_will_expire_at.expiresAt'|trans({ | ||
'%expiresAt%': expiresAt|format_datetime('short', 'short'), | ||
}) }} | ||
|
||
--- | ||
{{ loginLink }} | ||
--- | ||
|
||
{% endblock %} |
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
Oops, something went wrong.