backend-manager 2.5.87 → 2.5.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "2.5.87",
3
+ "version": "2.5.89",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -55,40 +55,43 @@ Module.prototype.signOutOfSession = function (uid, session) {
55
55
  assistant.log(`Signing out of all active sessions for ${uid} @ ${session}`, {environment: 'production'})
56
56
 
57
57
  await self.libraries.admin.database().ref(session)
58
- .orderByChild('uid')
59
- .equalTo(uid)
60
- .once('value')
61
- .then(async (snap) => {
62
- const data = snap.val() || {};
63
- const keys = Object.keys(data);
64
-
65
- for (var i = 0; i < keys.length; i++) {
66
- const key = keys[i];
67
-
68
- self.assistant.log(`Signing out: ${key}`, {environment: 'production'});
58
+ .orderByChild('uid')
59
+ .equalTo(uid)
60
+ .once('value')
61
+ .then(async (snap) => {
62
+ const data = snap.val() || {};
63
+ const keys = Object.keys(data);
64
+
65
+ for (var i = 0; i < keys.length; i++) {
66
+ const key = keys[i];
67
+
68
+ assistant.log(`Signing out ${key}...`, {environment: 'production'});
69
+
70
+ // Send signout command
71
+ await self.libraries.admin.database().ref(`${session}/${key}/command`)
72
+ .set('signout')
73
+ .catch(e => assistant.error(`Failed to signout of session ${key}`, e, {environment: 'production'}))
74
+
75
+ // Delay so the client has time to react to the command
76
+ await powertools.wait(5000);
77
+
78
+ // Delete session
79
+ await self.libraries.admin.database().ref(`${session}/${key}`)
80
+ .remove()
81
+ .catch(e => assistant.error(`Failed to delete session ${key}`, e, {environment: 'production'}))
82
+
83
+ assistant.log(`Signed out successfully: ${key}`, {environment: 'production'});
84
+
85
+ count++;
86
+ }
87
+
88
+ return resolve(count);
89
+ })
90
+ .catch(e => {
91
+ assistant.errorManager(`Session query error for session ${session}: ${e}`, {code: 500, sentry: true, send: false, log: true})
69
92
 
70
- // Send signout command
71
- await self.libraries.admin.database().ref(`${session}/${key}/command`)
72
- .set('signout')
73
- .catch(e => self.assistant.error(`Failed to signout of session ${key}`, e))
74
-
75
- // Delay so the client has time to react to the command
76
- await powertools.wait(5000);
77
-
78
- // Delete session
79
- self.libraries.admin.database().ref(`${session}/${key}`)
80
- .remove()
81
- .catch(e => self.assistant.error(`Failed to delete session ${key}`, e))
82
-
83
- count++;
84
- }
85
-
86
- return resolve(count);
87
- })
88
- .catch(e => {
89
- assistant.errorManager(`Session query error for session ${session}: ${e}`, {code: 500, sentry: true, send: false, log: true})
90
- return reject(count)
91
- })
93
+ return reject(count)
94
+ })
92
95
  });
93
96
  }
94
97