Module Login From Application

I have a module named staff and I want to direct login from the current application and tried with the below code but its not working, someone please help me out




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

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


if($identitystaff->authenticate())

{

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

}

else{

    echo $identitystaff->errorMessage; 

}