Bläddra i källkod

Fixed bug where the app would crash if a non-logged in user entered a room.

KrisVos130 9 år sedan
förälder
incheckning
7c1b42c44b
1 ändrade filer med 12 tillägg och 12 borttagningar
  1. 12 12
      app/server/server.js

+ 12 - 12
app/server/server.js

@@ -161,19 +161,19 @@ function Station(type) {
         Playlists.update({type: type}, {$push: {songs: default_song.mid}});
     }
     Meteor.publish(type, function () {
-        var userId = this.userId;
-        Meteor.thisIsA = this;
-        var username = Meteor.users.findOne(userId).profile.username;
-        Rooms.update({type: type}, {$push: {userList: username}});
-        this.onStop(function() {
-            var list = Rooms.findOne({type: type}).userList;
-            var index = list.indexOf(username);
-            if (index >= 0) {
-                list.splice( index, 1 );
-            }
+        var username = Meteor.users.findOne(this.userId).profile.username;
+        if (username !== undefined) {
+            Rooms.update({type: type}, {$push: {userList: username}});
+            this.onStop(function() {
+                var list = Rooms.findOne({type: type}).userList;
+                var index = list.indexOf(username);
+                if (index >= 0) {
+                    list.splice( index, 1 );
+                }
 
-            Rooms.update({type: type}, {$set: {userList: list}});
-        });
+                Rooms.update({type: type}, {$set: {userList: list}});
+            });
+        }
         return undefined;
     });
     var self = this;