fix: type mismatches and handle nullable values
This commit is contained in:
1 parent
c33c1b6bf0
commit
e7f3233dbc
9 files changed
+67
-47
No files matched your search
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Traits;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
|
||||
trait AuthenticatedUserTrait
|
||||
{
|
||||
public function getAuthenticatedUser(): User
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
if (null === $user) {
|
||||
throw new AuthenticationException();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user