backend-manager 2.3.10 → 2.3.13
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
package/src/cli/cli.js
CHANGED
|
@@ -895,7 +895,7 @@ function fix_firestoreRulesFile(self) {
|
|
|
895
895
|
|
|
896
896
|
if (!hasTemplate) {
|
|
897
897
|
log(chalk.red(`Could not find rules template. Please edit ${name} file and add`), chalk.red(`{{backend-manager}}`), chalk.red(`to it.`));
|
|
898
|
-
|
|
898
|
+
return resolve()
|
|
899
899
|
}
|
|
900
900
|
|
|
901
901
|
let matchesVersion = contents.match(self.default.rulesVersionRegex);
|
|
@@ -927,7 +927,7 @@ function fix_realtimeRulesFile(self) {
|
|
|
927
927
|
|
|
928
928
|
if (!hasTemplate) {
|
|
929
929
|
log(chalk.red(`Could not find rules template. Please edit ${name} file and add`), chalk.red(`{{backend-manager}}`), chalk.red(`to it.`));
|
|
930
|
-
|
|
930
|
+
return resolve()
|
|
931
931
|
}
|
|
932
932
|
|
|
933
933
|
let matchesVersion = contents.match(self.default.rulesVersionRegex);
|
|
@@ -16,16 +16,17 @@ Module.prototype.main = function () {
|
|
|
16
16
|
self.Api.resolveUser({adminRequired: true})
|
|
17
17
|
.then(async (user) => {
|
|
18
18
|
const uid = _.get(user, 'auth.uid', null);
|
|
19
|
-
const id = _.get(payload.data.payload, 'id', '
|
|
19
|
+
const id = _.get(payload.data.payload, 'id', 'app');
|
|
20
|
+
const session = `sessions/${id}`;
|
|
20
21
|
|
|
21
|
-
assistant.log(`Getting active sessions for ${uid} @ ${
|
|
22
|
+
assistant.log(`Getting active sessions for ${uid} @ ${session}`, {environment: 'production'})
|
|
22
23
|
|
|
23
|
-
await self.libraries.admin.database().ref(
|
|
24
|
+
await self.libraries.admin.database().ref(session)
|
|
24
25
|
.orderByChild('uid')
|
|
25
26
|
.equalTo(uid)
|
|
26
27
|
.once('value')
|
|
27
28
|
.then(async (snap) => {
|
|
28
|
-
const data = snap.val();
|
|
29
|
+
const data = snap.val() || {};
|
|
29
30
|
return resolve({data: data});
|
|
30
31
|
})
|
|
31
32
|
.catch(e => {
|
|
@@ -16,34 +16,20 @@ Module.prototype.main = function () {
|
|
|
16
16
|
self.Api.resolveUser({adminRequired: true})
|
|
17
17
|
.then(async (user) => {
|
|
18
18
|
const uid = _.get(user, 'auth.uid', null);
|
|
19
|
-
const id = _.get(payload.data.payload, 'id', '
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
.then(async (snap) => {
|
|
28
|
-
const data = snap.val();
|
|
29
|
-
const keys = Object.keys(data || {});
|
|
30
|
-
for (var i = 0; i < keys.length; i++) {
|
|
31
|
-
const key = keys[i];
|
|
32
|
-
self.assistant.log(`Signing out: ${key}`, {environment: 'production'});
|
|
33
|
-
await self.libraries.admin.database().ref(`${id}/${key}/command`).set('signout').catch(e => self.assistant.error(`Failed to signout ${key}`, e))
|
|
34
|
-
await powertools.wait(3000);
|
|
35
|
-
await self.libraries.admin.database().ref(`${id}/${key}`).remove().catch(e => self.assistant.error(`Failed to delete ${key}`, e))
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
.catch(e => {
|
|
39
|
-
console.error('Session query error', e);
|
|
40
|
-
})
|
|
19
|
+
const id = _.get(payload.data.payload, 'id', 'app');
|
|
20
|
+
const session = `sessions/${id}`;
|
|
21
|
+
|
|
22
|
+
let count = 0;
|
|
23
|
+
|
|
24
|
+
await self.signOutOfSession(uid, session).then(r => count += r);
|
|
25
|
+
// Legacy for somiibo and old electron-manager
|
|
26
|
+
await self.signOutOfSession(uid, 'gatherings/online').then(r => count += r);
|
|
41
27
|
|
|
42
28
|
await self.libraries.admin
|
|
43
29
|
.auth()
|
|
44
30
|
.revokeRefreshTokens(uid)
|
|
45
31
|
.then(() => {
|
|
46
|
-
return resolve({data: {message: `Successfully signed ${uid} out of all sessions`}});
|
|
32
|
+
return resolve({data: {sessions: count, message: `Successfully signed ${uid} out of all sessions`}});
|
|
47
33
|
})
|
|
48
34
|
.catch(e => {
|
|
49
35
|
return reject(assistant.errorManager(`Failed to sign out of all sessions: ${e}`, {code: 500, sentry: false, send: false, log: false}).error)
|
|
@@ -56,5 +42,39 @@ Module.prototype.main = function () {
|
|
|
56
42
|
|
|
57
43
|
};
|
|
58
44
|
|
|
45
|
+
Module.prototype.signOutOfSession = function (uid, session) {
|
|
46
|
+
const self = this;
|
|
47
|
+
const Manager = self.Manager;
|
|
48
|
+
const Api = self.Api;
|
|
49
|
+
const assistant = self.assistant;
|
|
50
|
+
const payload = self.payload;
|
|
51
|
+
|
|
52
|
+
return new Promise(async function(resolve, reject) {
|
|
53
|
+
assistant.log(`Signing out of all active sessions for ${uid} @ ${session}`, {environment: 'production'})
|
|
54
|
+
let count = 0;
|
|
55
|
+
|
|
56
|
+
await self.libraries.admin.database().ref(session)
|
|
57
|
+
.orderByChild('uid')
|
|
58
|
+
.equalTo(uid)
|
|
59
|
+
.once('value')
|
|
60
|
+
.then(async (snap) => {
|
|
61
|
+
const data = snap.val() || {};
|
|
62
|
+
const keys = Object.keys(data);
|
|
63
|
+
for (var i = 0; i < keys.length; i++) {
|
|
64
|
+
const key = keys[i];
|
|
65
|
+
self.assistant.log(`Signing out: ${key}`, {environment: 'production'});
|
|
66
|
+
await self.libraries.admin.database().ref(`${session}/${key}/command`).set('signout').catch(e => self.assistant.error(`Failed to signout ${key}`, e))
|
|
67
|
+
// await powertools.wait(3000);
|
|
68
|
+
// await self.libraries.admin.database().ref(`${session}/${key}`).remove().catch(e => self.assistant.error(`Failed to delete ${key}`, e))
|
|
69
|
+
count++;
|
|
70
|
+
}
|
|
71
|
+
return resolve(count);
|
|
72
|
+
})
|
|
73
|
+
.catch(e => {
|
|
74
|
+
assistant.errorManager(`Session query error for session ${session}: ${e}`, {code: 500, sentry: true, send: false, log: true})
|
|
75
|
+
return reject(count)
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
59
79
|
|
|
60
80
|
module.exports = Module;
|