lundi 21 décembre 2015

Detect a change in the dynamic segment

I have an authenticated route with a dynamic segment :slug that is used as separate organizations' short names. Within each organization there are individuals and groups. It's possible that different organizations will have the same individual IDs and group IDs.

So the URLs /bigcompany/s/individual/1 and /smallcompany/s/individual/1 are both valid and will take you to the individual with ID=1 for each of those companies.

router.js

Router.map(function() {
    this.route('authenticated', { path: '/:slug' }, function() {
        this.resource('individual',  { path: 's/individual/:id' }, function() {
            ...
        });
        this.resource('groups', { path: 's/groups' }, function() {
            this.route('group', { path: ':id' });
        });
    });

    this.route('login', { path: ':slug/s/login' });
});

After I log in from /bigcompany/s/login, it takes me to /bigcompany/s/individual/1 and loads the model for that individual.

The problem is that I can directly change the URL in the browser from bigcompany to smallcompany and it will go ahead and load the model for /smallcompany/s/individual/1.

Is there a way that if a user directly edits the URL in the browser to a different :slug that it will log the user out of the original :slug and load the login page for the new :slug?




Aucun commentaire:

Enregistrer un commentaire