Alveoli
Alveoli

Reputation: 1212

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.

Upvotes: 12

Views: 8772

Answers (1)

SylvainB
SylvainB

Reputation: 4820

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!

Upvotes: 27

Related Questions