Login To Modules Form Out Side The Module

Is it possible to login to module from out side the module as shown as below?

ie:





$authStaff =array('username'=>'staff','password'=>'admin');

$identitystaff = new  StaffIdentity($authStaff['username'],$authStaff['password']);


if($identitystaff->authenticate())

{

      Yii::app()->getModule('staff')->user->login($identitystaff);

}