App::before

Please put the App::before code to your app/filter function.

It will check the permission regarding user, group and module.

you can change the database structure and the code regarding your requirements.