Take the 2-minute tour ×

I'm trying to authenticate with a custom user provider, and the default login form.

The login part seems to work, because if I put an incorrect password it says 'bad credentials'. And if I put the correct password and catch the redirect, I can see my username in the toolbar.

But after the redirect, I get There is no user provider for user "Myapp\MainBundle\Document\User\User"

My user provider is configured like this:

# security.yml
        id: user_manager
        security: false
        pattern: ^/
            login_path: /login
            check_path: /login_check
            path:   /logout
            target: /
        anonymous: true

# config.yml
        class: Myapp\MainBundle\Service\User\UserManager
        factory_service: doctrine_mongodb
        factory_method:  getRepository
        arguments: [ 'MyappMainBundle:User\User' ]
            - [ setEncoder, [ @security.encoder_factory ] ]

This is the user provider (the abstract class extends from DocumentRepository, and implements UserProviderInterface):

namespace Myapp\MainBundle\Service\User;

use Myvendor\UserBundle\Service\User\AbstractUserManager;
use Myapp\MainBundle\Document\User\User;

class UserManager extends AbstractUserManager {
    public function createUser() {
        return new User;

    public function supportsClass($class) {
        return $class === 'Myapp\MainBundle\Document\User\User';

How can this happen? Why does it find the provider for the login, but then fail on the next request?

Symfony version: 2.1.3


I debugged the code that comes right before that exception and found this was being catched (for the only provider I have): "Symfony\Component\Security\Core\Exception\UnsupportedUserException" "Instances of "Myapp\MainBundle\Document\User\User" are not supported.. How can this be possible? I even tried returning true in supportsClass()

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Found my problem. This exception is thrown in refreshUser(). There I checked for the instance of the User class, like shown in the documentation, but I made a mistake in the namespace. There was a 'use' statement for a non-existent class, and it didn't throw any php errors.

share|improve this answer

Your Answer


