Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement UserInterface to work around Symfony core changes #1477

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Resources/contao/classes/BackendUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,23 @@ public function navigation($blnShowAll=false)

return $arrModules;
}

/**
* {@inheritdoc}
*/
public function getRoles()
{
// User not loaded
if (!$this->intId) {
return [];
}

$roles = ['ROLE_USER'];

if ($this->isAdmin) {
$roles[] = 'ROLE_ADMIN';
}

return $roles;
}
}
13 changes: 13 additions & 0 deletions src/Resources/contao/classes/FrontendUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,17 @@ protected function setUserFromDb()
}
}
}

/**
* {@inheritdoc}
*/
public function getRoles()
{
// User not loaded
if (!$this->intId) {
return [];
}

return ['ROLE_MEMBER'];
}
}
35 changes: 34 additions & 1 deletion src/Resources/contao/library/Contao/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Contao;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;


Expand Down Expand Up @@ -95,7 +96,7 @@
*
* @author Leo Feyer <https://github.com/leofeyer>
*/
abstract class User extends \System
abstract class User extends \System implements UserInterface
{

/**
Expand Down Expand Up @@ -730,6 +731,38 @@ public function isMemberOf($id)
return false;
}

/**
* {@inheritdoc}
*/
public function getPassword()
{
return '';
}

/**
* {@inheritdoc}
*/
public function getSalt()
{
return null;
}

/**
* {@inheritdoc}
*/
public function getUsername()
{
return $this->username;
}

/**
* {@inheritdoc}
*/
public function eraseCredentials()
{
// do nothing
}


/**
* Set all user properties from a database record
Expand Down