IronRouter Authorization Controller

I am wondering if anyone will be able to demonstrate how to use the global “up” action in the class of the router controller that handles user authentication and displays the corresponding route / pattern based on the result.

My use case is having an AppController that acts as an authentication firewall and blocks any actions by the child controller when the user logs off. For instance.

// Create a primary app controller stub with the auth firewall AppController = RouteController.extend({}); // Extend the AppController with all the other app routes MainController = AppController.extend({}); 

Any help would be appreciated!

+6
source share
1 answer

On my blog written in meteor, I use the code:

 AppController = RouteController.extend({ before:function(){ if(_.isNull(Meteor.user())){ Router.go(Router.path('home')); } } }) AdminPostController = AppController.extend({ waitOn: function() { return App.subs.posts} }); Router.map(function(){ this.route('submitPost', { path: '/submitPost', controller:'AdminPostController', template:'postCreate' }); this.route('editPost', { path: '/post/:slug/edit', controller:'AdminPostController', template:'postEdit' }); }) 
+5
source

Source: https://habr.com/ru/post/952536/


All Articles