WIP, copied code from yii-usr and preparing to run under Yii 2.0