nodebb-plugin-session-sharing 7.1.5 → 7.1.7
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/static/lib/main.js
CHANGED
|
@@ -49,7 +49,8 @@ $(document).ready(function () {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (config.sessionSharing.loginOverride) {
|
|
52
|
-
|
|
52
|
+
const params = utils.params();
|
|
53
|
+
if (data.url === 'login' && params && !params.local) {
|
|
53
54
|
$('#content').html('');
|
|
54
55
|
redirect(config.sessionSharing.loginOverride, e);
|
|
55
56
|
}
|
|
@@ -79,8 +80,8 @@ $(document).ready(function () {
|
|
|
79
80
|
data.url = null;
|
|
80
81
|
redirect(config.sessionSharing.registerOverride, e);
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
-
if (config.sessionSharing.loginOverride && data.url.startsWith('login')) {
|
|
83
|
+
const params = utils.params();
|
|
84
|
+
if (config.sessionSharing.loginOverride && data.url.startsWith('login') && params && !params.local) {
|
|
84
85
|
data.url = null;
|
|
85
86
|
redirect(config.sessionSharing.loginOverride, e);
|
|
86
87
|
}
|
|
@@ -1,68 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const winston = require.main.require('winston');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var meta = module.parent.require('./meta');
|
|
9
|
-
|
|
10
|
-
var settings;
|
|
5
|
+
const db = require.main.require('./src/database');
|
|
6
|
+
const batch = require.main.require('./src/batch');
|
|
7
|
+
const meta = require.main.require('./src/meta');
|
|
11
8
|
|
|
12
9
|
module.exports = {
|
|
13
10
|
name: 'Convert remote-to-local user ID from hash to sorted set',
|
|
14
11
|
timestamp: Date.UTC(2017, 9, 19),
|
|
15
|
-
method: function (
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
method: async function () {
|
|
13
|
+
try {
|
|
14
|
+
const progress = this.progress;
|
|
18
15
|
// Reload plugin settings and grab appID setting
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
settings = _settings;
|
|
22
|
-
winston.verbose('getting data');
|
|
23
|
-
if (settings.secret) {
|
|
24
|
-
// session-sharing is set up, execute upgrade
|
|
25
|
-
db.getObject((settings.name || 'appId') + ':uid', next);
|
|
26
|
-
} else {
|
|
27
|
-
// No secret set, skip upgrade as completed.
|
|
28
|
-
setImmediate(next, true);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
// Save a backup of the hash data in another key
|
|
33
|
-
function (hashData, next) {
|
|
34
|
-
db.rename((settings.name || 'appId') + ':uid', 'backup:' + (settings.name || 'appId') + ':uid', function (err) {
|
|
35
|
-
next(err, hashData);
|
|
36
|
-
});
|
|
37
|
-
},
|
|
16
|
+
const settings = await meta.settings.get('session-sharing');
|
|
17
|
+
winston.verbose('getting data');
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var values = [];
|
|
43
|
-
|
|
44
|
-
for(var remoteId in hashData) {
|
|
45
|
-
if (hashData.hasOwnProperty(remoteId)) {
|
|
46
|
-
values.push(remoteId);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
progress.total = values.length;
|
|
50
|
-
winston.verbose('saving into db');
|
|
51
|
-
async.eachSeries(values, function (value, next) {
|
|
52
|
-
progress.incr();
|
|
53
|
-
db.sortedSetAdd((settings.name || 'appId') + ':uid', hashData[value], value, next);
|
|
54
|
-
}, next);
|
|
55
|
-
}
|
|
56
|
-
], function (err) {
|
|
57
|
-
if (typeof err === 'boolean') {
|
|
58
|
-
// No upgrade needed
|
|
59
|
-
return callback();
|
|
60
|
-
} else if (err && err.message === 'WRONGTYPE Operation against a key holding the wrong kind of value') {
|
|
61
|
-
// Likely script already run, all is well
|
|
62
|
-
err = null;
|
|
19
|
+
if (!settings.secret) {
|
|
20
|
+
// No secret set, skip upgrade as completed.
|
|
21
|
+
return;
|
|
63
22
|
}
|
|
64
23
|
|
|
65
|
-
|
|
66
|
-
|
|
24
|
+
const pluginKey = (settings.name || 'appId') + ':uid';
|
|
25
|
+
// session-sharing is set up, execute upgrade
|
|
26
|
+
const hashData = await db.getObject(pluginKey);
|
|
27
|
+
|
|
28
|
+
await db.rename(pluginKey, 'backup:' + pluginKey);
|
|
29
|
+
|
|
30
|
+
winston.verbose('constructing array');
|
|
31
|
+
const values = Object.keys(hashData);
|
|
32
|
+
|
|
33
|
+
progress.total = values.length;
|
|
34
|
+
winston.verbose('saving into db');
|
|
35
|
+
await batch.processArray(values, async (batchValues) => {
|
|
36
|
+
progress.incr(batchValues.length);
|
|
37
|
+
await db.sortedSetAdd(pluginKey, batchValues.map(v => hashData[v]), batchValues);
|
|
38
|
+
}, {
|
|
39
|
+
batch: 500,
|
|
40
|
+
});
|
|
41
|
+
} catch (err) {
|
|
42
|
+
if (err && err.message !== 'WRONGTYPE Operation against a key holding the wrong kind of value') {
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
67
46
|
},
|
|
68
47
|
};
|