iron-router

Materialize: dropdown in “if” statement doesn't work

一曲冷凌霜 提交于 2019-11-28 01:29:28
问题 I tried to implement a dropdown list that is only visible when the user is signed in. The dropdown list works when outside the "if" statement but not inside. The buttons "Foo" and dropdown button are shown, however it doesn't "dropdown". header.html <!-- Header --> <template name="header"> <nav> <div class="nav-wrapper"> <a class="brand-logo" href="{{pathFor 'home'}}">Logo</a> <ul id="nav-mobile" class="right hide-on-med-and-down"> {{#if currentUser}} <!-- dropdown1 trigger --> <li> <a class=

How to redirect after user has just logged in or just logged out

杀马特。学长 韩版系。学妹 提交于 2019-11-27 20:17:54
It seems Deps.autorun is the way to go but Router.go doesn't seem to work within Deps.autorun. Here is an example with three routes: index , signin and dashboard : Router.configure({layoutTemplate: 'layout'}); Router.map(function() { this.route('index', {path: '/'}); this.route('signin'); this.route('dashboard'); }); var mustBeSignedIn = function(pause) { if (!(Meteor.user() || Meteor.loggingIn())) { Router.go('signin'); } else { this.next(); } }; var goToDashboard = function(pause) { if (Meteor.user()) { Router.go('dashboard'); } else { this.next(); } }; Router.onBeforeAction(mustBeSignedIn,

Authentication on Server side routes in Meteor

倾然丶 夕夏残阳落幕 提交于 2019-11-27 19:54:14
What is the best way (most secure and easiest) to authenticate a user for a server side route? Software/Versions I'm using the latest Iron Router 1.* and Meteor 1.* and to begin, I'm just using accounts-password. Reference code I have a simple server side route that renders a pdf to the screen: both/routes.js Router.route('/pdf-server', function() { var filePath = process.env.PWD + "/server/.files/users/test.pdf"; console.log(filePath); var fs = Npm.require('fs'); var data = fs.readFileSync(filePath); this.response.write(data); this.response.end(); }, {where: 'server'}); As an example, I'd

How to serve static content (images, fonts etc.) using iron router

旧街凉风 提交于 2019-11-27 19:20:30
I just started working with iron router on meteor. I need to show an image on homepage. I was able to configure route for 'home' using the client side routing. For static files I tried to google and found that adding a server side route might help. So, I added the following code on server's router.js. Router.map(function() { this.route('files', { path: '/files/:path(*)', action: function() { var path = this.params.path; console.log('will serve static content @ '+path); this.response.sendfile(path); } }); }); When I try to access http://localhost:3000/files/someImage.png , it says that no route

Meteor and the /private directory

只愿长相守 提交于 2019-11-27 18:58:20
问题 I'm using the /private directory in Meteor 1.0.3 at the moment to store and serve up pdf documents to the browser. As an example, I have a folder structure like so: /application-name /private /files /users /user-name /pdf-file1.pdf I have a template with a button click event. In this event I make a couple of calls to Meteor methods and finally a server side Iron Router go('render-pdf') method. In these Meteor methods I use fs node.js to: (1) check if the /user-name directory exists, and if it

Server side routes in Iron Router and Meteor

…衆ロ難τιáo~ 提交于 2019-11-27 18:29:38
问题 Forward It seems that in Meteor, we cannot call a server side route to render a file to the page without some sort of work-around from our normal workflow, from what I've read about server side routes. I hope I'm wrong about this, and there's a simple way to achieve what I'm looking to do... ** Sorry if this is a little long, but I think in this case providing more background and context is warranted ** Software/Versions I'm using the latest Iron Router 1.* and Meteor 1.* and to begin, I'm

meteorjs iron-router waitOn and using as data on rendered

▼魔方 西西 提交于 2019-11-27 13:59:32
问题 I try to get the returned data in my Template.rendered function. The current code is: this.route('editCat', { layoutTemplate : 'layoutCol2Left', template : 'modCategoriesEdit', path : '/mod/categories/edit/:_id', yieldTemplates : _.extend(defaultYieldTemplates, { 'navigationBackend' : {to : 'contentLeft'} }), waitOn : function () { return Meteor.subscribe('oneCat', this.params._id); }, data : function () { return Categories.findOne({_id : this.params._id}); } }); In this block i wait on the

Redirecting not logged-in users with iron-router… Again

感情迁移 提交于 2019-11-27 11:28:12
问题 I am fighting with the common need for redirecting a user to a login page if he is not logged-in (Meteor v0.8.0 on Windows 7). There are several similar questions on stackoverflow, but no answer seems to work for me. Won't work #1: render() From the documentation: onBeforeAction: function () { if (!Meteor.user()) { // render the login template but keep the url in the browser the same this.render('login'); // stop the rest of the before hooks and the action function this.stop(); } }, Two

Redirect after Login using Meteor and Iron Router

只愿长相守 提交于 2019-11-27 10:54:30
问题 I'm using the built in loginButtons options with Meteor and I would like to redirect after a user logs in. Using the built in web snippets means I can't use the callback with Meteor.loginwithPassword and I can't see any hooks inside Iron-Router to do the redirect. Any suggestions? 回答1: Meteor often renders so quickly that the page is being loaded before the user has been defined. You need to use Meteor.loggingIn() to account for the situation in which you are in the process of logging in.

How to get the query parameters in Iron-router?

南笙酒味 提交于 2019-11-27 10:51:20
问题 I am trying to get the query parameters in the url. There doesn't seem to be an easy way to do this... which leaves me with the feeling that I must have missed a something in the doc. 回答1: iron router >= 1.0 A route's query parameters are available as properties of this.params.query . If your URL looked like: /posts/5?sort_by=created_at then this.params.query.sort_by would equal 'created_at' . iron router < 1.0 A route's query parameters are available as properties of this.params . If your