How Can I Set Default Rule For My Application?

hi i have user table with 8 fields say username,password,Flag (Yes/No) etc…

i want to set default rule for my application say "If Flag(user table field) value is No, then user should be logout fourcefully from my application (if user loogedin)…

Flag field value can change any time… for example assume when user comes for authentication at that time Flag value is Yes and after sometime Flag value change to No at that time user should logout from my application fourcefully… after that he is not supposed to perform any action as a logged in user… so i want to check every time that my user table field value is yes then only user can perform any action (may be sound like is looged in or not?)

may be you can say i want to add one more rule for authentication check is if user is logged in is not enough but user field Flag is also Yes…

i am really blank now, how do it? is there any way to do like this?

Thanks in advance

You can load user info every time in beforeAction (or somewhere else) and force logout() if flag is off.

That would be the simplest.

think for that i have write before action method in every model… i want to keep it in one place from where i can apply it to my whole application

You don’t need to.

Extend all of your controllers from some base controller (I’m pretty sure it’s already done, see components/Controller), and define your filter there.

can you please give me some startup code… i mean how to check condition… bcz i am totally confused for checking this condition