added safety to setUserId (when called twice)

This commit is contained in:
Kevin Jahns
2015-12-30 16:37:35 +01:00
parent 98d87cb26d
commit bdf290adb2
3 changed files with 8 additions and 3 deletions

View File

@@ -63,8 +63,12 @@ module.exports = function (Y/* :any */) {
return this.y.db.stopGarbageCollector()
}
setUserId (userId) {
this.userId = userId
return this.y.db.setUserId(userId)
if (this.userId == null) {
this.userId = userId
return this.y.db.setUserId(userId)
} else {
return null
}
}
onUserEvent (f) {
this.userEventListeners.push(f)