1

I want to test if my currentUser have in his users collection

-> profileType: "NULL" (default value).

and if profileType != "NULL" i will redirect the user to an other template.

I don't where will be the best place to do it ?

  • In the router whith a onBeforeAction
  • on a client helper
  • call a method in the server side

Thanks in advance

ldls
  • 159
  • 1
  • 8

3 Answers3

0

Depends on the behavior you want.

onBeforeAction if you put it here, your app will wait and show your loading template while it checks this.

If you put it in a client helper you will have a noticable UI change when the data changes.

If you make a server side method then you should also utilize onBeforeAction to wait on your call to be made.

thatgibbyguy
  • 4,033
  • 3
  • 23
  • 39
0

This is a very broad question #Idls, but here's some places to start.

I want to test if my currentUser have in his users collection

-> profileType: "NULL" (default value).

Look at the Collections2 and SimpleSchema Meteor packages. Understand and implement this.

and if profileType != "NULL" i will redirect the user to an other template.

I don't where will be the best place to do it ?

This question will help you with that.

Michael Cole
  • 15,473
  • 7
  • 79
  • 96
0

By far the simplest and quickest way is just to do it in Blaze:

{{#if profileType}}
  {{> nonNullProfileTypeTemplate}}
{{else}}
  {{> nullProfileTypeTemplate}}
{{/if}}

This takes advantage of the fact that null is false-y.

You could do it in the router too but there's little advantage to that approach in this case IMO.

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39