What exactly is the user state in ZfcUser?

2019-04-07 11:58发布

Can anybody tell me, what the "user state" in the ZfcUser is doing exactly and why we may need it? What does this user state mean (I assume it's not the role meant by it)?

2条回答
走好不送
2楼-- · 2019-04-07 12:02

User state can be used by adding two values to your config array in zfcuser.global.php

In order to use state as active/inactive for example you can add this:

'enable_user_state' => true, 'allowed_login_states' => array(1),

Now the user state has to be set to 1 from an admin, otherwise login will fail for that specific user.

查看更多
Root(大扎)
3楼-- · 2019-04-07 12:28

Basically it's a flag to indicate the state of a user. Sometimes you need to be able to disable users, or otherwise affect their 'state' without actually deleting them from the table. That's what the state column is intended for if you use such a system.

As a simple example, think of a temporarily banned user on a forum, you don't want to delete them, so you set their state to banned, and only allow users who aren't banned to log in.

Of course there could be more states to indicate other things, such as an account that hasn't yet been validated by way of confirmation email, or requires administrator approval, whatever makes sense in your user ecosystem really. It could be you don't need any at all, in which case you can safely ignore it.

查看更多
登录 后发表回答