I have a method in a handler:
function index( event, rc, prc ){
if (auth.isLoggedIn()) {
event.setView( "top_secret/main/index" );
} else {
relocate( "top_secret/login.index" );
}
}
And I am getting this error message:
No matching Method/Function for user defined function (auth).isLoggedIn() found
I believe that the config is correct, cbauth is installed and I have the UserService and User models defined.
I believe you have to inject auth for that to work.
There is a mixin which allows you to use auth().isLoggedIn();
If you want to use auth.isLoggedIn()
you will need
property name="auth" inject="authenticationService@cbauth";
Always reinit after changing injections.
Hope that helps.
Actually, the helpers are method calls. You have auth.
and not auth()
, big difference. So are you trying to call the mixin or are you injecting the service somehow?
The examples in the documentation are not correct.
auth.authenticate( username, password );
auth.isLoggedIn();
auth.getUser();
auth.logout();
Then yes. That’s wrong. Can you send me the link of these docs?
We can add a disclaimer to this page.
On this page we show how to inject or use the auth() helper… we should probably show both examples