Take the 2-minute tour ×

I've wrote a helper for the 3 conditions of users being logged in. I've verified that the CurrentUsers collection is being populated on user login with console.log on client.js and browser console. I'm not sure if I'm going about this wrong or if its a little error. There are no error messages in server console or browser console but nothing shows up for the condition of 0 users being logged in.


CurrentUsers = new Meteor.Collection("currentUsers")

if (Meteor.isClient) {
  Template.lobby.nousers = function() {
    return CurrentUsers.find().count() === 0;
  Template.lobby.oneuser = function(){
    return CurrentUsers.find().count() === 1;
  Template.lobby.twousers = function(){
    return CurrentUsers.find().count() === 2;

if (Meteor.isServer) {
  Meteor._onLogin  = function (userId){
    if(CurrentUsers.find({user: userId}).count()===0){
      CurrentUsers.insert({user: userId})
   Meteor._onLogout  = function (userId){
    CurrentUsers.remove({user: userId})



    {{loginButtons align = "right"}}
<template name = "lobby">
{{#if nousers}}
<div class = "nouser">
    Hello please sign in to enter the game lobby.
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You are missing {{> lobby}} in your body.

    {{loginButtons align = "right"}}
    {{> lobby}}

Also, as far as I'm aware Meteor doesn't offer login/logout hooks, so Meteor._onLogin and Meteor._onLogout won't work out of the box: https://github.com/meteor/meteor/issues/1074

This event-hooks package might be interesting for you.

share|improve this answer
Thanks @tobold check this package out this is what the hooks are for github.com/erundook/meteor-profile-online –  user2755667 Jan 16 at 8:44

Your Answer

