Trustroots / trustroots

Travellers' community for sharing, hosting and getting people together.
https://www.trustroots.org
GNU Affero General Public License v3.0
398 stars 137 forks source link

bug: user can't join tribes #821

Closed guaka closed 5 years ago

guaka commented 5 years ago

Describe the bug

Support query:

I can't for some reason join any tribes, my account I think predates them but I was inactive for a long time so maybe that's why.

(account created in 2015)

Follow up from 2 days ago:

No, still, getting the “failed to join the tribe, try again” message.

To Reproduce Not sure.

Expected behavior Joining tribe.

Desktop (please complete the following information): Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0

for those with access: see https://trustroots.zendesk.com/inbox/conversations/2278

guaka commented 5 years ago

reproduced this locally (as this user), this is the server side 500 error:

TypeError: Cannot read property 'equals' of undefined
    at /Users/guaka/trustroots/modules/users/server/controllers/users.profile.server.controller.js:1437:29
    at baseFindIndex (/Users/guaka/trustroots/node_modules/lodash/lodash.js:802:11)
    at findIndex (/Users/guaka/trustroots/node_modules/lodash/lodash.js:7258:14)
    at Function.find (/Users/guaka/trustroots/node_modules/lodash/lodash.js:5079:21)
    at isUserMemberOfTribe (/Users/guaka/trustroots/modules/users/server/controllers/users.profile.server.controller.js:1436:20)
    at /Users/guaka/trustroots/modules/users/server/controllers/users.profile.server.controller.js:954:11
    at nextTask (/Users/guaka/trustroots/node_modules/async/dist/async.js:5324:14)
    at Object.waterfall (/Users/guaka/trustroots/node_modules/async/dist/async.js:5334:5)
    at exports.joinTribe (/Users/guaka/trustroots/modules/users/server/controllers/users.profile.server.controller.js:949:9)
    at Layer.handle [as handle_request] (/Users/guaka/trustroots/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/guaka/trustroots/node_modules/express/lib/router/route.js:137:13)
    at /Users/guaka/trustroots/modules/users/server/policies/users.server.policy.js:143:16
    at tryCatcher (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.successAdapter [as _fulfillmentHandler0] (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/nodeify.js:23:30)
    at Promise._settlePromise (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/promise.js:566:21)
    at Promise._settlePromise0 (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/guaka/trustroots/node_modules/acl/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)

ping @mrkvon @simison

guaka commented 5 years ago

Fixed it.

Problem was that user.member didn't contain any tribe IDs, only since. 8 other users also had this problem.

Fixed it by setting .member to [].

Contacted all 9 users that they can join tribes again. Also added some code for this to a start of a bin/admin/dbConsistency.js script.