This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from Senjutsumo/add-roles
Add roles
- Loading branch information
Showing
11 changed files
with
197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace SumoCoders\FrameworkMultiUserBundle\Entity; | ||
|
||
use DateTime; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Security\Core\Role\Role; | ||
|
||
/** | ||
* @ORM\Entity | ||
* @ORM\Table | ||
* @ORM\HasLifecycleCallbacks | ||
*/ | ||
class UserRole extends Role | ||
{ | ||
/** | ||
* @var int | ||
* | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string") | ||
*/ | ||
private $roleName; | ||
|
||
/** | ||
* @var DateTime | ||
* | ||
* @ORM\Column(type="datetime") | ||
*/ | ||
private $createdOn; | ||
|
||
/** | ||
* @var DateTime | ||
* | ||
* @ORM\Column(type="datetime") | ||
*/ | ||
private $editedOn; | ||
|
||
public function __construct(string $roleName) | ||
{ | ||
parent::__construct($roleName); | ||
|
||
$this->roleName = $roleName; | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getRole(): string | ||
{ | ||
return $this->roleName; | ||
} | ||
|
||
public function getCreatedOn(): DateTime | ||
{ | ||
return $this->createdOn; | ||
} | ||
|
||
public function getEditedOn(): DateTime | ||
{ | ||
return $this->editedOn; | ||
} | ||
|
||
/** | ||
* @ORM\PrePersist | ||
*/ | ||
public function onPrePersist(): void | ||
{ | ||
$this->createdOn = new DateTime(); | ||
$this->editedOn = new DateTime(); | ||
} | ||
|
||
/** | ||
* @ORM\PreUpdate | ||
*/ | ||
public function onPreUpdate(): void | ||
{ | ||
$this->editedOn = new DateTime(); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->roleName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
services: | ||
multi_user_form_add_base_user: | ||
class: SumoCoders\FrameworkMultiUserBundle\Form\AddBaseUserType | ||
arguments: | ||
- "@translator" | ||
tags: | ||
- { name: form.type } | ||
|
||
multi_user_form_edit_base_user: | ||
class: SumoCoders\FrameworkMultiUserBundle\Form\EditBaseUserType | ||
arguments: | ||
- "@translator" | ||
tags: | ||
- { name: form.type } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ change: | |
second: repeat password | ||
submit: Set new password | ||
user: | ||
roles: User roles | ||
header: | ||
title: | ||
login: Login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace SumoCoders\FrameworkMultiUserBundle\User; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use SumoCoders\FrameworkMultiUserBundle\Entity\BaseUser; | ||
use SumoCoders\FrameworkMultiUserBundle\Security\PasswordResetToken; | ||
use SumoCoders\FrameworkMultiUserBundle\User\Interfaces\User; | ||
|
@@ -20,6 +21,7 @@ public function __construct(EncoderFactory $encoderFactory) | |
'test', | ||
'Wouter Sioen', | ||
'[email protected]', | ||
new ArrayCollection(['ROLE_USER']), | ||
1 | ||
); | ||
$user->encodePassword($encoderFactory->getEncoder($user)); | ||
|
@@ -31,6 +33,7 @@ public function __construct(EncoderFactory $encoderFactory) | |
'reset', | ||
'reset', | ||
'[email protected]', | ||
new ArrayCollection(['ROLE_USER']), | ||
2, | ||
PasswordResetToken::generate() | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters