]> cat aescling's git repositories - mastodon.git/commitdiff
fix(streaming): req.scopes can be nullable (#16823)
authorSasha Sorokin <10401817+Brawaru@users.noreply.github.com>
Wed, 13 Oct 2021 03:02:55 +0000 (10:02 +0700)
committerGitHub <noreply@github.com>
Wed, 13 Oct 2021 03:02:55 +0000 (05:02 +0200)
When checking for required OAuth scopes, an unexpected error could
happen due to missing (null-y) req.scopes. This commit fixes that by
checking if req.scopes are present before checking if any required
scopes are present, otherwise it skips that straight to rejection.

streaming/index.js

index 67cd48b43e89d408d2139dc6c857b318622f2e5c..8b7477a44c844f73ae776646550c0f885ac76f85 100644 (file)
@@ -430,7 +430,7 @@ const startWorker = (workerId) => {
       requiredScopes.push('read:statuses');
     }
 
-    if (requiredScopes.some(requiredScope => req.scopes.includes(requiredScope))) {
+    if (req.scopes && requiredScopes.some(requiredScope => req.scopes.includes(requiredScope))) {
       resolve();
       return;
     }