Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is the user state in ZfcUser?

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

like image 881
Maxim Zubarev Avatar asked Mar 07 '13 13:03

Maxim Zubarev


2 Answers

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.

like image 200
ibo_s Avatar answered Oct 16 '22 09:10

ibo_s


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.

like image 36
Crisp Avatar answered Oct 16 '22 08:10

Crisp