Remove / Replace the username field with email using FOSUserBundle in Symfony2 / Symfony3

前端 未结 8 785
半阙折子戏
半阙折子戏 2020-12-02 05:06

I only want to have email as mode of login, I don\'t want to have username. Is it possible with symfony2/symfony3 and FOSUserbundle?

I read here http://groups.google

8条回答
  •  天命终不由人
    2020-12-02 05:30

    If none of them works, a quick and dirty solution would be

    public function setEmail($email)
    {
        $email = is_null($email) ? '' : $email;
        parent::setEmail($email);
        $this->setUsername(uniqid()); // We do not care about the username
    
        return $this;
    }
    

提交回复
热议问题