Controll views loading

I’m develop application with authenthification module. App has state ready:true when auth is complete.
app.js entry

var app = core.create({
		id:         'AuthApp',
		name:       'Test aspp',
		version:    '0.1.0',
		debug:      true,
		start:      'Auth',
		main:       '/sidemenu'
	});

	app = webix.extend({
		Auth: function(user, pass){
			///Auth code return promise
		},
        
		LoadPage:  function(page, param){
			var main = this.config.main;
			var rslt = main + '/' + page;
			this.show(rslt);
		}
	}, app);
    
	return app;

auth.js

define(['app', 'login_form'], function(app, form){
    return {
        $ui: login_form,
        $oninit: function(view){
            view.$$('submit').attachEvent('onItemClick', function(){
                var data = view.$$('form').getValues();
                app.Auth(data)
                    .then(app.LoadPage.bind(app, app.config.main))
                    .catch(function(){
                        view.$$('form').markInvalid("login", "Login Error!");
                    });
            });
        }
    }
});

If write URL manualy in browser #!/sidemenu/Other_Page - user have access without auth. How I can disable access to other page?

Hello,

The recommended way for such cases is to control the navigation by some ‘session’ helper that will store the information about the currently logged user (if any), ping server for the current session and perform routing.

It can also contain the logic of logging in and out. So your ‘auth.js’ may contain just view, the login form and logic will be set apart.

app.js:

define([
        ...
	"helpers/session",
], function( ..., session ){
	var app = core.create({...})
	app.use(session);
	return app;
});

session.js:

define([
	"models/session" //maybe some serverside model
], function(session){
    var current_user; //to store session information
return  {
    $oninit:function(app){
	// set ping interval if needed
    },
   $onurl:function(url, config){
        if(url =="auth"){ //your 'auth.js' file
           //let user login, after successful logic create 'current_user'
	     return false;
        }
         else if (!current_user && url.indexOf("auth") !== 0){
	    /*if there's no logged in user and they try to access another url,
            redirect to logic form*/
	       return false;
        }
});

Returning false within the $onurl handler prevents from navigating to this url.

Thanks!