4 Some context: It is possible for a non-github user to follow a link to a public
5 room that doesn't allow non-github users to join. In that case the frontend
6 must know to not allow the user to join and the backend/API must prevent that
9 function userCanJoinRoom(userProviders
, troupeProviders
) {
10 // By default (undefined or null or empty array) all providers are allowed
11 // why all three? Because you might not have set it (undefined) or because it
12 // came back from the db and got upgraded to an empty array because of the
14 if (!troupeProviders
|| !troupeProviders
.length
) {
18 // To be safe, we assume the user has no identity which is non-sensical, but
19 // safer than picking one as that will mask bugs.
20 userProviders
= userProviders
|| [];
22 // If the user has at least one provider that's allowed, then she can join
24 return userProviders
.some(up
=> {
25 return troupeProviders
.some(tp
=> {
30 module
.exports
= userCanJoinRoom
;