mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into 292_activity_acl
This commit is contained in:
@@ -108,7 +108,7 @@ class PasswordController extends AbstractController
|
||||
$username = $query->get(TokenManager::USERNAME_CANONICAL);
|
||||
$hash = $query->getAlnum(TokenManager::HASH);
|
||||
$token = $query->getAlnum(TokenManager::TOKEN);
|
||||
$timestamp = $query->getInt(TokenManager::TIMESTAMP);
|
||||
$timestamp = $query->getAlnum(TokenManager::TIMESTAMP);
|
||||
$user = $this->getDoctrine()->getRepository(User::class)
|
||||
->findOneByUsernameCanonical($username);
|
||||
|
||||
|
@@ -33,22 +33,18 @@ use function in_array;
|
||||
class User implements AdvancedUserInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
protected ?int $id = null;
|
||||
|
||||
/**
|
||||
* Array where SAML attributes's data are stored.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
*/
|
||||
private $attributes;
|
||||
private array $attributes;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
@@ -64,32 +60,26 @@ class User implements AdvancedUserInterface
|
||||
private ?string $email = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=150,
|
||||
* nullable=true,
|
||||
* unique=true)
|
||||
*/
|
||||
private $emailCanonical;
|
||||
private ?string $emailCanonical = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $enabled = true;
|
||||
private bool $enabled = true;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\GroupCenter",
|
||||
* inversedBy="users")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
|
||||
*/
|
||||
private $groupCenters;
|
||||
private Collection $groupCenters;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=200)
|
||||
@@ -98,12 +88,10 @@ class User implements AdvancedUserInterface
|
||||
private string $label = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
* sf4 check: in yml was false by default !?
|
||||
*/
|
||||
private $locked = true;
|
||||
private bool $locked = true;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
@@ -117,20 +105,16 @@ class User implements AdvancedUserInterface
|
||||
private ?Scope $mainScope = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $password;
|
||||
private string $password = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @internal must be set to null if we use bcrypt
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $salt;
|
||||
private ?string $salt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=UserJob::class)
|
||||
@@ -138,22 +122,18 @@ class User implements AdvancedUserInterface
|
||||
private ?UserJob $userJob = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
private $username;
|
||||
private string $username = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(
|
||||
* type="string",
|
||||
* length=80,
|
||||
* unique=true,
|
||||
* nullable=true)
|
||||
*/
|
||||
private $usernameCanonical;
|
||||
private ?string $usernameCanonical = null;
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
@@ -406,10 +386,7 @@ class User implements AdvancedUserInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
public function setEnabled(bool $enabled)
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
|
@@ -545,7 +545,7 @@ class ExportManager
|
||||
if (null === $centers) {
|
||||
$centers = $this->authorizationHelper->getReachableCenters(
|
||||
$this->user,
|
||||
$role
|
||||
$role->getRole(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ class ExportManager
|
||||
'center' => $center,
|
||||
'circles' => $this->authorizationHelper->getReachableScopes(
|
||||
$this->user,
|
||||
$element->requiredRole(),
|
||||
$element->requiredRole()->getRole(),
|
||||
$center
|
||||
),
|
||||
];
|
||||
|
@@ -61,7 +61,7 @@ class TokenManager
|
||||
throw new UnexpectedValueException('username should not be empty to generate a token');
|
||||
}
|
||||
|
||||
$timestamp = $expiration->getTimestamp();
|
||||
$timestamp = (string) $expiration->getTimestamp();
|
||||
$hash = hash('sha1', $token . $username . $timestamp . $this->secret);
|
||||
|
||||
return [
|
||||
@@ -72,7 +72,7 @@ class TokenManager
|
||||
];
|
||||
}
|
||||
|
||||
public function verify($hash, $token, User $user, $timestamp)
|
||||
public function verify($hash, $token, User $user, string $timestamp)
|
||||
{
|
||||
$token = hex2bin(trim($token));
|
||||
|
||||
|
@@ -247,7 +247,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
$expectedResult,
|
||||
Scope $testedScope,
|
||||
User $user,
|
||||
Role $role,
|
||||
string $role,
|
||||
Center $center,
|
||||
$message
|
||||
) {
|
||||
|
@@ -88,7 +88,7 @@ final class TokenManagerTest extends KernelTestCase
|
||||
$this->assertFalse($tokenManager->verify($hash . '5', $token, $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token . '25', $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token, $user->setUsernameCanonical('test2'), $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token, $user, $timestamp + 1));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token, $user, (string) ($timestamp + 1)));
|
||||
}
|
||||
|
||||
public function testVerifyExpiredFails()
|
||||
|
Reference in New Issue
Block a user