Navigate and stop

How can I trigger a app.router.navigate() and then stop the execution?

I have some code like this:

if ( isAuth == true ) {
      app.router.navigate('/dashboard/')
};

// do login
app.router.navigate('/auth/login/');

now, if isAuth is true, page is changed to /dashboard/, but execution is not stopped and immediatly after i’m redirected to the /auth/login/ page

How can I stop the code execution when navigating to other pages ?

it should be

if(isAuth){
  app.router.navigate('/dashboard/');
} else {
  app.router.navigate('/auth/login/');
}

or

app.router.navigate(isAuth?'/dashboard/':'/auth/login/');

It was Just an example.
I can’t punt everything inside an if/else

This is something that i currently use:

 cordova.plugins.SecureKeyStore.get(function (res) {
     if ( res ) {
         auth = JSON.parse(res);

         if ( auth.username && auth.password ) {
             app.request.setup({
                 headers: {
                     'Authorization': 'Basic '+Base64.encode(auth.username+':'+auth.password)
                 }
             });

             app.router.navigate('/current-orders/');
         }
     }
 }, function (error) {
     auth = {}; 
     app.router.navigate('/auth/login/');
 }, "auth");

 console.log('fallback to failed auth');

as you can see, usually I put a fallback on the bottom, just in case the SecureKeyStore.get didn’t run properly.
similarly, I don’t use “else” for if ( res ). Because I don’t like to put tons of if/else everywhere. It much easier and cleaner to navigate out of the view and stop the rest of the code.

Question is more about coding structuring. In F7 if navigate launched there is no way to stop/prevent it. You need to structure your logic to make all the checks before calling navigate