简体   繁体   English

FOSUserBundle:仅管理员确认注册(无电子邮件)

[英]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: 使用FOSUserBundle,我需要以下工作流程:

  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. 我知道这个问题: Symfony2 / FosUSerBundle中经过管理员审查的注册,但这是一个不同的问题,因为OP使用确认电子邮件。

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) 问题是我看不到如何在不激活确认机制(令牌+电子邮件)的情况下强制FOSUserBundle不启用创建用户

Anyone? 任何人? Thank you in advance. 先感谢您。

I think you have to override FOSUser controller . 我认为您必须重写FOSUser控制器 The page shows exactly the controller you need to edit :) 该页面准确显示了您需要编辑的控制器:)

You will have to : 你不得不 :

  1. Persist the user with active set to false 使用active设置为false坚持用户
  2. Manually set the active flag of the user to true , with any Admin generator you want (or not). 使用您想要(或不需要)的任何Admin生成器,将用户的活动标记手动设置 true

You could override the user constructor and set the user field 'locked' to true on all new accounts. 您可以覆盖用户构造函数,并在所有新帐户上将用户字段“锁定”设置为true。 Then in your admin section, you can manually edit the user and set it 'locked' to false after you setup the custom property. 然后,在管理部分中,您可以手动编辑用户,并在设置自定义属性后将其“锁定”设置为false。

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;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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