Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-2880: Added PasswordExpiredException #309

Merged
merged 4 commits into from
May 24, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use eZ\Publish\Core\Repository\Values\Content\Content;
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
use eZ\Publish\Core\Repository\Values\User\User as APIUser;
use Ibexa\Core\MVC\Symfony\Security\Exception\PasswordExpiredException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Throwable;

Expand Down Expand Up @@ -156,7 +156,7 @@ public function testCheckPostAuthWithExpiredUser(): void
)
);

$this->expectException(CredentialsExpiredException::class);
$this->expectException(PasswordExpiredException::class);
$this->expectExceptionMessage('User account has expired.');

$this->userChecker->checkPostAuth(new User($apiUser));
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/MVC/Symfony/Security/UserChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use eZ\Publish\API\Repository\UserService;
use eZ\Publish\Core\MVC\Symfony\Security\UserInterface as EzUserInterface;
use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
use Ibexa\Core\MVC\Symfony\Security\Exception\PasswordExpiredException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -46,7 +46,7 @@ public function checkPostAuth(UserInterface $user): void
}

if ($this->userService->getPasswordInfo($user->getAPIUser())->isPasswordExpired()) {
$exception = new CredentialsExpiredException('User account has expired.');
$exception = new PasswordExpiredException('User account has expired.');
$exception->setUser($user);

throw $exception;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\Core\MVC\Symfony\Security\Exception;

use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;

final class PasswordExpiredException extends CustomUserMessageAccountStatusException
{
public function __construct(string $message = 'User account has expired.')
{
parent::__construct($message);
}
}