Deploying Symfony2 app getting fosuserbundle errors

I have installed my Symfony project on another computer with the same specifications, and I receive the following error when I login with fosuserbundle:

Authentication request could not be processed due to a system problem.

I can’t find anything of interest in the app/logs files. I run the app in dev mode. Cleared cache both manually and from the console. I setup the db with doctrine:database:create. It works to create a new user with fos:user:create and it’s successfully saved to the database.

I have no idea where to go from here.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Check to make sure your database is up to date. This fixed my issue when I received this error.

php app/console doctrine:schema:update --dump-sql

edit: spelling

Solution 2

Had the same issue while working in dev environment. I updated my User’s model, and every time I tried to login I had your error. Solved by running:

app/console cache:clear

EDIT: Had the same issue again. This time it’s happened because I moved my project to another server and forgot to update parameters.yml to match the server’s MySQL credentials.

Solution 3

It looks like that the error:

Authentication request could not be processed due to a system problem.

is too generic and does not tell anything about where the problem is (there is an issue opened about this matter here).

I solved my issue by checking the logs and see what happened (in var/logs/dev.log), hoping this helps someone.

In my specific case, there was a wrong parameter in parameters.yml about database.

Solution 4

You might have set a wrong password in your parameters.yml because of which it might not be able to connect to the DB.
The above mentioned error occurs when the app is not able to connect to DB to check if the user is authentic.
(I also faced the same error and this was my problem, hope it helps)

Solution 5

In a deploy process usually it’s an environment problem (assuming that the app works fine in a dev station).
FOSUserBundle it’s great but for some reason it doesn’t show very well the problems behind it.

As the error message says: “.. could not be processed due to a system problem.”

if cleaning the cache nor updating the schema works, I would recommend try to bypass FOSUserBundle (usually the issue is between your code/configuration and the server environment) and let your bundle with the default errorhandler and logger inform any problem.

in my case it was a driver problem. (install pdo)

to bypass it, the simplest way is to remove security to a controller_action in security.yml

access_control:
{ path: ^/SomeCRUD, role: IS_AUTHENTICATED_ANONYMOUSLY }

then, if you access it, it should be able to log the issue and you should be able to fix it.

hope it helps

Solution 6

Make sure that your User entity implements the UserInterface

<?php

namespace UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * BaseUser
 */
class BaseUser implements UserInterface
{
    /**
     * @var integer
     */
    protected $id;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var string
     */
    protected $username;

    /**
     * @var string
     */
    protected $password;

    /**
     * @var string
     */ 
    protected $email;

    /**
     * @var string
     * 
     */
    protected $roles;

    /**
     * @var boolean
     */
    protected $isActive;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     * @return BaseUser
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set username
     *
     * @param string $username
     * @return BaseUser
     */
    public function setUsername($username)
    {
        $this->username = $username;

        return $this;
    }

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

    /**
     * Set password
     *
     * @param string $password
     * @return BaseUser
     */
    public function setPassword($password)
    {
        if (!is_null($password)) {
            $this->password = $password;
        }

        return $this;
    }

    /**
     * Get password
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return BaseUser
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set roles
     *
     * 
     * @return BaseUser
     */
    public function setRoles($roles)
    {
        $this->roles = $roles;
    }

    /**
     * Get roles
     */
    public function getRoles()
    {
        // Do what ever make sense to you here 
        return explode("|", $this->roles)
    }

    /**
     * Set isActive
     *
     * @param boolean $isActive
     * @return BaseUser
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

    /**
     * Get isActive
     *
     * @return boolean 
     */
    public function getIsActive()
    {
        return $this->isActive;
    }

    public function eraseCredentials()
    {
    }

    public function getSalt()
    {
        return null;
    }
}

Solution 7

If you’ve generated the database using doctrine:database:create, maybe your charset isn’t appropriate. Because User table has a serialized field (roles) a wrong encoding could be the cause.

You can check this looking into app/logs and your database collation.

Alternatively, check this answer

Solution 8

I had the same problem. I was able to build and populate the database with php app/console doctrine:schema:update --force; php app/console doctrine:fixtures:load; but the symfony app couldn’t access the database.

The problem was I’d set database_host: 127.0.0.1 in parameters.yml but mysql was expecting me to connect through localhost. Updating parameters.yml fixed the problem. I’m still confused as to why the command line stuff worked…

Solution 9

I was having the exact same issue. And the steps I took were the following:

  1. I cleared the cache
  2. I brought down all my db tables and recreated them again via my migrations
  3. I replaced where I had used single quotes(‘) with double quotes(“) in my entity annotations for arguments to constraint methods

    Example

    //src/SomeBundle/Model/user.php
    <?php
    /**
    *
    * @Assert\File(
    *  maxSize='512k',
    *  mimeTypes={'image/png', 'image/jpeg', 'image/gif'},
    *  mimeTypesMessage= 'Please upload a valid png, gif or jpeg file below 512Kb'
    * )
    */
    private $profilePic;
    
    ?>
    

    This got replaced with

    <?php
    /**
    *
    * @Assert\File(
    *  maxSize="512k",
    *  mimeTypes={"image/png", "image/jpeg", "image/gif"},
    *  mimeTypesMessage= "Please upload a valid png, gif or jpeg file below 512Kb"
    * )
    */
    private $profilePic;
    ?>
    

After doing this, I tried the authentication again and it worked!

Solution 10

I had the problem Symfony 2.3 and when I execute app/console doctrine:schema:update –dump-sql this is the result.

DROP INDEX UNIQ_957A647992FC23A8 ON fos_user;
DROP INDEX UNIQ_957A6479A0D96FBF ON fos_user;
ALTER TABLE fos_user DROP username, DROP username_canonical, DROP email, DROP email_canonical, DROP enabled, DROP salt, DROP password, DROP last_login, DROP locked, DROP expired, DROP expires_at, DROP confirmation_token, DROP password_requested_at, DROP roles, DROP credentials_expired, DROP credentials_expire_at;

It started working again just after I updated doctrine-bundle from 1.2 to 1.3.

Info:

https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2140

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply