In 2nd code block in your question you defined user
component for module AgentModule
.
If i understand right, somewhere in your view or controller you use Yii::app()->user->loginUrl
, right? To get url defined in AgentModule
you should use Yii::app()->user->controller->module->user
but only while in AgentModule
context.
Easiest way to make it different is to define somewhere login urls for module, and for app, and just use this predefined urls.
Try reading about module compoents here: http://www.yiiframework.com/wiki/27/how-to-access-a-component-of-a-module-from-within-the-module-itself/