Fix roles generation
Add symfony class uses
// src/Rapsys/UserBundle/Entity/User.php
namespace Rapsys\UserBundle\Entity;
// src/Rapsys/UserBundle/Entity/User.php
namespace Rapsys\UserBundle\Entity;
-class User implements \Symfony\Component\Security\Core\User\AdvancedUserInterface, \Serializable {
+use Rapsys\UserBundle\Entity\Group;
+use Symfony\Component\Security\Core\User\UserInterface;
+use Doctrine\Common\Collections\ArrayCollection;
+
+class User implements UserInterface, \Serializable {
*/
public function __construct() {
$this->active = false;
*/
public function __construct() {
$this->active = false;
- $this->groups = new \Doctrine\Common\Collections\ArrayCollection();
+ $this->groups = new ArrayCollection();
- public function addGroup(\Rapsys\UserBundle\Entity\Group $group) {
+ public function addGroup(Group $group) {
$this->groups[] = $group;
return $this;
$this->groups[] = $group;
return $this;
*
* @param \Rapsys\UserBundle\Entity\Group $group
*/
*
* @param \Rapsys\UserBundle\Entity\Group $group
*/
- public function removeGroup(\Rapsys\UserBundle\Entity\Group $group) {
+ public function removeGroup(Group $group) {
$this->groups->removeElement($group);
}
$this->groups->removeElement($group);
}
}
public function getRoles() {
}
public function getRoles() {
- return $this->groups->toArray();
+ $roles = [ 'ROLE_USER' ];
+
+ foreach($this->groups->toArray() as $group) {
+ $roles[] = $group->getRole();
+ }
+
+ return array_unique($roles);
}
public function getSalt() {
}
public function getSalt() {
) = unserialize($serialized);
}
) = unserialize($serialized);
}
- public function isAccountNonExpired() {
- return true;
- }
-
- public function isAccountNonLocked() {
- return true;
- }
-
- public function isCredentialsNonExpired() {
- return true;
- }
-
+ //XXX: was from vendor/symfony/security-core/User/AdvancedUserInterface.php, see if it's used anymore
public function isEnabled() {
return $this->active;
}
public function isEnabled() {
return $this->active;
}