nodebb-plugin-session-sharing 7.1.6 → 7.2.0
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/lib/controllers.js +7 -4
- package/library.js +10 -0
- package/package.json +1 -1
- package/static/lib/main.js +2 -2
- package/static/templates/admin/plugins/session-sharing.tpl +76 -58
package/lib/controllers.js
CHANGED
|
@@ -6,19 +6,22 @@ const Controllers = {};
|
|
|
6
6
|
|
|
7
7
|
Controllers.renderAdminPage = async (req, res) => {
|
|
8
8
|
const groupData = await groups.getGroupsFromSet('groups:visible:createtime', 0, -1);
|
|
9
|
-
res.render('admin/plugins/session-sharing', {
|
|
9
|
+
res.render('admin/plugins/session-sharing', {
|
|
10
|
+
title: 'Session Sharing',
|
|
11
|
+
groups: groupData,
|
|
12
|
+
});
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
Controllers.retrieveUser = async (req, res) => {
|
|
13
16
|
const main = module.parent.exports;
|
|
14
17
|
const remoteId = req.query.id;
|
|
15
|
-
|
|
18
|
+
|
|
16
19
|
if (!remoteId) {
|
|
17
20
|
return res.status(400).json({
|
|
18
21
|
error: 'no-id-supplied',
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
try {
|
|
23
26
|
const userObj = await main.getUser(remoteId);
|
|
24
27
|
|
|
@@ -42,7 +45,7 @@ Controllers.process = async (req, res) => {
|
|
|
42
45
|
error: 'no-token-provided',
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
|
-
|
|
48
|
+
|
|
46
49
|
try {
|
|
47
50
|
const uid = await main.process(req.body.token);
|
|
48
51
|
|
package/library.js
CHANGED
|
@@ -279,7 +279,17 @@ plugin.updateUserProfile = async (uid, userData, isNewUser) => {
|
|
|
279
279
|
winston.debug('[session-sharing] Updating profile fields:', obj);
|
|
280
280
|
obj.uid = uid;
|
|
281
281
|
try {
|
|
282
|
+
const { trustPayloadEmail } = await meta.settings.get('session-sharing');
|
|
283
|
+
let email = '';
|
|
284
|
+
if (trustPayloadEmail === 'on') {
|
|
285
|
+
email = obj.email;
|
|
286
|
+
delete obj.email;
|
|
287
|
+
}
|
|
282
288
|
userObj = await user.updateProfile(uid, obj);
|
|
289
|
+
if (trustPayloadEmail && email) {
|
|
290
|
+
await user.setUserField(uid, 'email', email);
|
|
291
|
+
await user.email.confirmByUid(uid, 0);
|
|
292
|
+
}
|
|
283
293
|
|
|
284
294
|
// If it errors out, not that big of a deal, continue anyway.
|
|
285
295
|
if (!userObj) {
|
package/package.json
CHANGED
package/static/lib/main.js
CHANGED
|
@@ -80,8 +80,8 @@ $(document).ready(function () {
|
|
|
80
80
|
data.url = null;
|
|
81
81
|
redirect(config.sessionSharing.registerOverride, e);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
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) {
|
|
85
85
|
data.url = null;
|
|
86
86
|
redirect(config.sessionSharing.loginOverride, e);
|
|
87
87
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<div class="acp-page-container">
|
|
2
|
+
<!-- IMPORT admin/partials/settings/header.tpl -->
|
|
3
|
+
|
|
4
|
+
<div class="row m-0">
|
|
5
|
+
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
|
|
6
|
+
<form role="form" class="session-sharing-settings">
|
|
7
|
+
<div class="mb-4">
|
|
8
|
+
<h5 class="fw-bold tracking-tight settings-header">General</h5>
|
|
9
|
+
|
|
7
10
|
<div class="mb-3">
|
|
8
11
|
<label class="form-label" for="name">Base Name</label>
|
|
9
12
|
<input type="text" id="name" name="name" title="Base Name" class="form-control" placeholder="appId" />
|
|
@@ -37,10 +40,10 @@
|
|
|
37
40
|
</p>
|
|
38
41
|
</div>
|
|
39
42
|
</div>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
<div class="mb-4">
|
|
45
|
+
<h5 class="fw-bold tracking-tight settings-header">Session Handling</h5>
|
|
46
|
+
|
|
44
47
|
<div class="mb-3">
|
|
45
48
|
<label class="form-label" for="behaviour">Cookie changes</label>
|
|
46
49
|
<select class="form-control" name="behaviour" id="behaviour">
|
|
@@ -53,7 +56,7 @@
|
|
|
53
56
|
<div class="form-check">
|
|
54
57
|
<input class="form-check-input" type="checkbox" id="adminRevalidate" name="adminRevalidate" />
|
|
55
58
|
<label class="form-check-label">
|
|
56
|
-
<span
|
|
59
|
+
<span>Apply revalidation rules to administrators as well</span>
|
|
57
60
|
</label>
|
|
58
61
|
<p class="form-text">
|
|
59
62
|
Administrators are exempt from the <code>revalidate</code> behaviour because a
|
|
@@ -67,7 +70,7 @@
|
|
|
67
70
|
<div class="form-check">
|
|
68
71
|
<input class="form-check-input" type="checkbox" id="noRegistration" name="noRegistration" />
|
|
69
72
|
<label class="form-check-label">
|
|
70
|
-
<span
|
|
73
|
+
<span>Do not automatically create NodeBB accounts for unrecognized users</span>
|
|
71
74
|
</label>
|
|
72
75
|
<p class="form-text">
|
|
73
76
|
By default, an unrecognized user id found in a payload cookie will have a local NodeBB account automatically created for it. If enabled,
|
|
@@ -77,7 +80,7 @@
|
|
|
77
80
|
<div class="form-check">
|
|
78
81
|
<input class="form-check-input" type="checkbox" id="updateProfile" name="updateProfile" />
|
|
79
82
|
<label class="form-check-label">
|
|
80
|
-
<span
|
|
83
|
+
<span>Automatically update local profile information with information found in shared cookie</span>
|
|
81
84
|
</label>
|
|
82
85
|
<div class="form-text">
|
|
83
86
|
Basic information such as username and id are required, while others are optional (first name, last name, etc.). Enable this setting to allow
|
|
@@ -87,28 +90,28 @@
|
|
|
87
90
|
<div class="form-check">
|
|
88
91
|
<input class="form-check-input" type="checkbox" id="allowBannedUsers" name="allowBannedUsers" />
|
|
89
92
|
<label class="form-check-label">
|
|
90
|
-
<span
|
|
93
|
+
<span>Allow banned users to be logged in and placed into banned user group</span>
|
|
91
94
|
</label>
|
|
92
95
|
<p class="form-text">
|
|
93
96
|
By default banned users arent logged in and an error is thrown. If enabled, banned users are logged in and placed in the banned group.
|
|
94
97
|
</p>
|
|
95
98
|
</div>
|
|
96
|
-
<div class="form-check">
|
|
99
|
+
<div class="form-check mb-3">
|
|
97
100
|
<input class="form-check-input" type="checkbox" id="syncGroupJoin" name="syncGroupJoin" />
|
|
98
101
|
<label class="form-check-label">
|
|
99
|
-
<span
|
|
102
|
+
<span>Automatically join groups if present in payload</span>
|
|
100
103
|
</label>
|
|
101
104
|
</div>
|
|
102
|
-
<div class="form-check">
|
|
105
|
+
<div class="form-check mb-3">
|
|
103
106
|
<input class="form-check-input" type="checkbox" id="syncGroupLeave" name="syncGroupLeave" />
|
|
104
107
|
<label class="form-check-label">
|
|
105
|
-
<span
|
|
108
|
+
<span>Automatically leave groups if not present in payload</span>
|
|
106
109
|
</label>
|
|
107
110
|
</div>
|
|
108
|
-
<div class="form-check">
|
|
111
|
+
<div class="form-check mb-3">
|
|
109
112
|
<input class="form-check-input" type="checkbox" id="syncGroupList" name="syncGroupList" />
|
|
110
113
|
<label class="form-check-label">
|
|
111
|
-
<span
|
|
114
|
+
<span>Select groups to join/leave</span>
|
|
112
115
|
</label>
|
|
113
116
|
</div>
|
|
114
117
|
<select class="form-select mb-3" id="syncGroups" name="syncGroups" multiple size="10">
|
|
@@ -146,10 +149,9 @@
|
|
|
146
149
|
</p>
|
|
147
150
|
</div>
|
|
148
151
|
</div>
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<div class="col-sm-10 col-12">
|
|
152
|
+
|
|
153
|
+
<div class="mb-4">
|
|
154
|
+
<h5 class="fw-bold tracking-tight settings-header">Payload Keys</h5>
|
|
153
155
|
<p>
|
|
154
156
|
In general, you should not need to change these values, as you should be adjusting your app's cookie's
|
|
155
157
|
JWT payload keys to match the defaults. However if circumstances require you to have different values,
|
|
@@ -158,6 +160,7 @@
|
|
|
158
160
|
<p class="form-text">
|
|
159
161
|
Default values are shown as placeholders in the corresponding input fields.
|
|
160
162
|
</p>
|
|
163
|
+
|
|
161
164
|
<div class="mb-3">
|
|
162
165
|
<label class="form-label" for="name">Unique ID</label>
|
|
163
166
|
<input type="text" id="payload:id" name="payload:id" title="Unique ID" class="form-control" placeholder="id">
|
|
@@ -166,6 +169,16 @@
|
|
|
166
169
|
<label class="form-label" for="payload:email">Email</label>
|
|
167
170
|
<input type="text" id="payload:email" name="payload:email" title="Email" class="form-control" placeholder="email">
|
|
168
171
|
</div>
|
|
172
|
+
<div class="form-check mb-3">
|
|
173
|
+
<input class="form-check-input" type="checkbox" id="trustPayloadEmail" name="trustPayloadEmail" />
|
|
174
|
+
<label class="form-check-label">
|
|
175
|
+
<span>Trust the email provided</span>
|
|
176
|
+
</label>
|
|
177
|
+
<p class="form-text">
|
|
178
|
+
If enabled, the email provided will be automatically verified.
|
|
179
|
+
Otherwise, the user will be emailed a confirmation link.
|
|
180
|
+
</p>
|
|
181
|
+
</div>
|
|
169
182
|
<div class="mb-3">
|
|
170
183
|
<label class="form-label" for="payload:username">Username</label>
|
|
171
184
|
<input type="text" id="payload:username" name="payload:username" title="Username" class="form-control" placeholder="username">
|
|
@@ -225,10 +238,10 @@
|
|
|
225
238
|
</p>
|
|
226
239
|
</div>
|
|
227
240
|
</div>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
241
|
+
|
|
242
|
+
<div class="mb-4">
|
|
243
|
+
<h5 class="fw-bold tracking-tight settings-header">Guest Handling</h5>
|
|
244
|
+
|
|
232
245
|
<div class="mb-3">
|
|
233
246
|
<label class="form-label" for="guestRedirect">Re-direct unauthenticated sessions (guests) to this address</label>
|
|
234
247
|
<input type="text" id="guestRedirect" name="guestRedirect" class="form-control" placeholder="https://...">
|
|
@@ -240,10 +253,10 @@
|
|
|
240
253
|
</p>
|
|
241
254
|
</div>
|
|
242
255
|
</div>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
256
|
+
|
|
257
|
+
<div class="mb-4">
|
|
258
|
+
<h5 class="fw-bold tracking-tight settings-header">Reverse Token</h5>
|
|
259
|
+
|
|
247
260
|
<div class="mb-3">
|
|
248
261
|
<div class="form-check">
|
|
249
262
|
<input type="checkbox" class="form-check-input" id="reverseToken" name="reverseToken">
|
|
@@ -259,32 +272,37 @@
|
|
|
259
272
|
</p>
|
|
260
273
|
</div>
|
|
261
274
|
</div>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
<
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
275
|
+
|
|
276
|
+
<div class="mb-4">
|
|
277
|
+
<h5 class="fw-bold tracking-tight settings-header">Account Search</h5>
|
|
278
|
+
<div class="col">
|
|
279
|
+
<div class="card">
|
|
280
|
+
<div class="card-body">
|
|
281
|
+
<h5 class="card-title">User Search</h5>
|
|
282
|
+
<input type="text" class="form-control" id="search" />
|
|
283
|
+
<p class="form-text">
|
|
284
|
+
Search for a username here to find their associated unique ID.
|
|
285
|
+
</p>
|
|
286
|
+
<p id="result"></p>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
<div class="col">
|
|
291
|
+
<div class="card">
|
|
292
|
+
<div class="card-body">
|
|
293
|
+
<h5 class="card-title">Remote ID Search</h5>
|
|
294
|
+
<input type="text" class="form-control" id="remote_search" />
|
|
295
|
+
<p class="form-text">
|
|
296
|
+
Enter a remote ID here to find their NodeBB user profile.
|
|
297
|
+
</p>
|
|
298
|
+
<p id="local_result"></p>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
283
302
|
</div>
|
|
284
|
-
</
|
|
303
|
+
</form>
|
|
285
304
|
</div>
|
|
286
|
-
</div>
|
|
287
|
-
</form>
|
|
288
|
-
|
|
289
|
-
<!-- IMPORT admin/partials/save_button.tpl -->
|
|
290
305
|
|
|
306
|
+
<!-- IMPORT admin/partials/settings/toc.tpl -->
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|