Skip to content

Commit 612e4fa

Browse files
committed
Implement PasswordAuthenticatedUserInterface when appropriate
1 parent b81b711 commit 612e4fa

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Model/User.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public function getId()
199199
return $this->id;
200200
}
201201

202+
public function getUserIdentifier(): string
203+
{
204+
return $this->username;
205+
}
206+
202207
/**
203208
* {@inheritdoc}
204209
*/
@@ -242,7 +247,7 @@ public function getEmailCanonical()
242247
/**
243248
* {@inheritdoc}
244249
*/
245-
public function getPassword()
250+
public function getPassword(): ?string
246251
{
247252
return $this->password;
248253
}

Model/UserInterface.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@
1111

1212
namespace FOS\UserBundle\Model;
1313

14+
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
1415
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;
1516

17+
if (interface_exists(PasswordAuthenticatedUserInterface::class)) {
18+
/**
19+
* @internal Only for back compatibility. Remove / merge when dropping support for Symfony 4
20+
*/
21+
interface CompatUserInterface extends PasswordAuthenticatedUserInterface, BaseUserInterface
22+
{
23+
}
24+
} else {
25+
/**
26+
* @internal Only for back compatibility. Remove / merge when dropping support for Symfony 4
27+
*/
28+
interface CompatUserInterface extends BaseUserInterface
29+
{
30+
}
31+
}
32+
1633
/**
1734
* Implementations of that interface must be serializable. The mechanism
1835
* being used to support serialization is up for the implementation.
@@ -23,7 +40,7 @@
2340
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2441
* @author Julian Finkler <julian@developer-heaven.de>
2542
*/
26-
interface UserInterface extends BaseUserInterface
43+
interface UserInterface extends CompatUserInterface
2744
{
2845
public const ROLE_DEFAULT = 'ROLE_USER';
2946

0 commit comments

Comments
 (0)