Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor template: What's the simplest way to check if a user is logged in?

I'm using Meteor's accounts-ui. Is there a way to check if the user is logged in on the template without writing custom helper code?

Pseudo code:

{{#if userIsLoggedIn }}
    You're logged in
{{/if}}

If not, what's the cleanest, most idiomatic way of doing it?

I only care about client-side here.

Thanks.

like image 520
Alveoli Avatar asked Apr 29 '15 13:04

Alveoli


1 Answers

Simple answer: check if the currentUser object exists.

{{#if currentUser }}
  You're logged in
{{/if}}

Yes, it is a default helper, no need to write anything else!

like image 50
SylvainB Avatar answered Sep 19 '22 19:09

SylvainB