Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/services/google_identity_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ services:
$tenantId: '%sfs_user.login.google_identity_platform.tenant_id%'

Softspring\UserBundle\GoogleIdentityPlatform\IdentityPlatformUserSynchronizer: ~

Softspring\UserBundle\Manager\IdentityPlatformSessionManager:
arguments:
$apiKey: '%sfs_user.login.google_identity_platform.api_key%'
$tenantId: '%sfs_user.login.google_identity_platform.tenant_id%'

Softspring\UserBundle\Manager\IdentityPlatformSessionManagerInterface:
alias: Softspring\UserBundle\Manager\IdentityPlatformSessionManager

Softspring\UserBundle\Security\IdentityPlatformAccessTokenHandler: ~
10 changes: 10 additions & 0 deletions src/Controller/Admin/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ public function usersCountWidget(): Response
'users' => $this->userManager->getRepository()->count(['admin' => false]),
'administrators' => $this->userManager->getRepository()->count(['admin' => true]),
'total' => $this->userManager->getRepository()->count([]),
'supports_confirmable' => $this->supportsConfirmableUsers(),
]);
}

public function usersPendingConfirmCountWidget(): Response
{
if (!$this->supportsConfirmableUsers()) {
return new Response('', Response::HTTP_NO_CONTENT);
}

return $this->render('@SfsUser/admin/users/widget-pending-confirm-count.html.twig', [
'count' => $this->userManager->getRepository()->count(['confirmedAt' => null]),
]);
Expand Down Expand Up @@ -188,4 +193,9 @@ public function resendConfirmationEmail(string $user, Request $request): Respons

return $this->redirectToRoute('sfs_user_admin_users_details', ['user' => $user]);
}

private function supportsConfirmableUsers(): bool
{
return $this->userManager->getEntityClassReflection()->implementsInterface(ConfirmableInterface::class);
}
}
2 changes: 2 additions & 0 deletions src/Controller/GoogleIdentityPlatformLoginController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Controller;

use RuntimeException;
Expand Down
40 changes: 23 additions & 17 deletions src/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function login(Request $request, TranslatorInterface $translator): Respon
{
/** @var Session $session */
$session = $request->getSession();
$manualLoginEnabled = $this->loginForm->supportsManualLogin();

$loginCheckParams = [];
if ($this->targetPathParameter && $targetPath = $request->query->get($this->targetPathParameter, $request->request->get($this->targetPathParameter))) {
Expand All @@ -52,33 +53,38 @@ public function login(Request $request, TranslatorInterface $translator): Respon
$authenticationErrorKey = class_exists('Symfony\Component\Security\Http\SecurityRequestAttributes') ? constant('Symfony\Component\Security\Http\SecurityRequestAttributes::AUTHENTICATION_ERROR') : (class_exists('Symfony\Component\Security\Core\Security') ? constant('Symfony\Component\Security\Core\Security::AUTHENTICATION_ERROR') : null);
$lastUserNameKey = class_exists('Symfony\Component\Security\Http\SecurityRequestAttributes') ? constant('Symfony\Component\Security\Http\SecurityRequestAttributes::LAST_USERNAME') : (class_exists('Symfony\Component\Security\Core\Security') ? constant('Symfony\Component\Security\Core\Security::LAST_USERNAME') : null);

$form = $this->createForm(get_class($this->loginForm), [
'_username' => $session->get($lastUserNameKey) ?? '',
'_password' => '',
], [
'action' => $this->generateUrl('sfs_user_login_check', $loginCheckParams),
]);
$form = null;

if ($request->attributes->has($authenticationErrorKey)) {
$form->addError(new FormError($request->attributes->get($authenticationErrorKey)));
} elseif ($session->has($authenticationErrorKey)) {
$error = $session->get($authenticationErrorKey);
if ($manualLoginEnabled) {
$form = $this->createForm(get_class($this->loginForm), [
'_username' => $session->get($lastUserNameKey) ?? '',
'_password' => '',
], [
'action' => $this->generateUrl('sfs_user_login_check', $loginCheckParams),
]);

if ($error instanceof TooManyLoginAttemptsAuthenticationException) {
$form->addError(new FormError($translator->trans($error->getMessageKey(), $error->getMessageData(), 'security')));
} else {
$form->addError(new FormError($session->get($authenticationErrorKey)->getMessage()));
}
if ($request->attributes->has($authenticationErrorKey)) {
$form->addError(new FormError($request->attributes->get($authenticationErrorKey)));
} elseif ($session->has($authenticationErrorKey)) {
$error = $session->get($authenticationErrorKey);

$session->remove($authenticationErrorKey);
if ($error instanceof TooManyLoginAttemptsAuthenticationException) {
$form->addError(new FormError($translator->trans($error->getMessageKey(), $error->getMessageData(), 'security')));
} else {
$form->addError(new FormError($session->get($authenticationErrorKey)->getMessage()));
}

$session->remove($authenticationErrorKey);
}
}

if (($response = $this->dispatchGetResponse(SfsUserEvents::LOGIN_ATTEMPT, new GetResponseFormEvent($form, $request))) instanceof Response) {
if ($form && ($response = $this->dispatchGetResponse(SfsUserEvents::LOGIN_ATTEMPT, new GetResponseFormEvent($form, $request))) instanceof Response) {
return $response;
}

return $this->render('@SfsUser/login/login.html.twig', [
'login_form' => $form,
'manual_login_enabled' => $manualLoginEnabled,
'oauth_services' => $this->oauthServices,
'google_identity_platform' => $this->googleIdentityPlatformConfig,
'register_params' => $loginCheckParams,
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/OauthLoginIntegrationController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Controller;

use RuntimeException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
2 changes: 2 additions & 0 deletions src/Doctrine/Filter/AdminFilter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Doctrine\Filter;

use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down
2 changes: 2 additions & 0 deletions src/Doctrine/Filter/UserFilter.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Doctrine\Filter;

use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/ConfirmableTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/EmailTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/EnabledTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/GoogleIdentityPlatformTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/NameSurnameTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/OwnerTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/PasswordRequestTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/RolesAdminTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/RolesFullTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Softspring\UserBundle\Model\RolesFullTrait as RolesFullTraitModel;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/RolesTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserAccessLatLongTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserAccessLocationTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserAvatarTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserHasLocalePreferenceTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserIdentifierEmailTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserIdentifierUsernameTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserLastLoginTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserMediaAvatarTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/UserPasswordTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/GetResponseUserEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Event;

use Softspring\Component\Events\GetResponseEventInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/RegisterExceptionEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Event;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/UserEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Event;

use Softspring\Component\Events\RequestEvent;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/UserInvitationEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Event;

use Softspring\Component\Events\RequestEvent;
Expand Down
2 changes: 2 additions & 0 deletions src/EventListener/Admin/AdministratorControllerListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\EventListener\Admin;

use Doctrine\ORM\EntityManagerInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/EventListener/Admin/UserControllerListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\EventListener\Admin;

use Doctrine\ORM\EntityManagerInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/EventListener/EmailInvitationListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\EventListener;

use Softspring\UserBundle\Event\UserInvitationEvent;
Expand Down
2 changes: 2 additions & 0 deletions src/EventListener/UserAccessEventSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\EventListener;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Form/AcceptInvitationForm.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Form;

use Softspring\UserBundle\Manager\UserManagerInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/Form/AcceptInvitationFormInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Form;

use Symfony\Component\Form\FormTypeInterface;
Expand Down
2 changes: 2 additions & 0 deletions src/Form/Admin/AccessHistoryListFilterForm.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Softspring\UserBundle\Form\Admin;

use Softspring\Component\DoctrinePaginator\Form\PaginatorForm;
Expand Down
Loading
Loading