What exactly is the user state in ZfcUser?
Asked Answered
S

2

7

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)?

Shockey answered 7/3, 2013 at 13:18 Comment(0)
K
6

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.

Kleist answered 7/3, 2013 at 13:44 Comment(0)
P
10

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.

Presentable answered 29/3, 2013 at 0:8 Comment(0)
K
6

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.

Kleist answered 7/3, 2013 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.