简体   繁体   中英

FOSUserBundle: registration confirmation by admin only (no email)

It looks like i'm the only one on the internet to need something like that, i'm out of options to search for a solution to this problem, but i'm sure people here will come to a solution :)

With FOSUserBundle, i want the following workflow:

  1. user fill in the registration form (generated by the bundle)
  2. they reach a confirmation page: "thank you, wait for validation by admin"
  3. the admin must validate each user by hand (because they have to set up a property on validation)

What i don't want is a confirmation email or any way for the user to validate its account by itself.

I'm aware of this question: Admin-reviewed registration in Symfony2 / FosUSerBundle but it's a different problem, because the OP uses confirmation emails.

The problem is that i don't see how to force FOSUserBundle not to enable the user on creation while not activating the confirmation mechanism (token + email)

Anyone? Thank you in advance.

I think you have to override FOSUser controller . The page shows exactly the controller you need to edit :)

You will have to :

  1. Persist the user with active set to false
  2. Manually set the active flag of the user to true , with any Admin generator you want (or not).

You could override the user constructor and set the user field 'locked' to true on all new accounts. Then in your admin section, you can manually edit the user and set it 'locked' to false after you setup the custom property.

public function __construct()
    {
        $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
        $this->enabled = false;
        $this->locked = true;
        $this->expired = false;
        $this->roles = array();
        $this->credentialsExpired = false;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM