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

PUGX UserProviders to fix supportsClass return value in FOS UserProviders #119

Closed
wants to merge 9 commits 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
10 changes: 10 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ services:
pugx_user_discriminator:
alias: pugx_user.manager.user_discriminator

# user providers
pugx_multi_user.user_provider.username:
class: PUGX\MultiUserBundle\Security\UserProvider
arguments: ["@fos_user.user_manager"]
public: false

pugx_multi_user.user_provider.username_email:
class: PUGX\MultiUserBundle\Security\EmailUserProvider
arguments: ["@fos_user.user_manager"]
public: false
13 changes: 13 additions & 0 deletions Security/EmailUserProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace PUGX\MultiUserBundle\Security;

use FOS\UserBundle\Security\EmailUserProvider as FOSEmailUserProvider;

class EmailUserProvider extends FOSEmailUserProvider {
public function supportsClass($class) {
$userClass = $this->userManager->getClass();
return $userClass === $class || is_subclass_of($class, $userClass) ||
(get_parent_class($class) === get_parent_class($userClass) && get_parent_class($class) !== false);
}
}
13 changes: 13 additions & 0 deletions Security/UserProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace PUGX\MultiUserBundle\Security;

use FOS\UserBundle\Security\UserProvider as FOSUserProvider;

class UserProvider extends FOSUserProvider {
public function supportsClass($class) {
$userClass = $this->userManager->getClass();
return $userClass === $class || is_subclass_of($class, $userClass) ||
(get_parent_class($class) === get_parent_class($userClass) && get_parent_class($class) !== false);
}
}