I'm hooking the canActivate callback to load a login model/view. My welcome view shows the login dialog in the activate callback, which works just fine. I would like to block activation of all views with the login, rather than simply calling it after view activation. It seems like my login model/view won't load unless at least one other view is loaded. Once I load welcome, I can get the model to display fine when attempting to navigate to other views where it is hooked into canActivate.
Here's what it looks like in my welcome model:
self.activate = function () {
if( session.token() == null){
app.showDialog(new Login())
}
}
and what it looks like in my other models:
self.canActivate = function () {
if( session.token() == null){
return app.showDialog(new Login()).then(function(){
return true;
})
}
else{
return true;
}
}
The canActivate is returned a promise from the login dialog and only activates after the dialog closes itself on successful login. Can I show the dialog before activating any view?