nodebb-plugin-sso-facebook 4.0.3 → 4.0.5
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/library.js +9 -11
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -26,18 +26,15 @@
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
Facebook.init = function (params, callback) {
|
|
29
|
-
|
|
29
|
+
const hostHelpers = require.main.require('./src/routes/helpers');
|
|
30
30
|
|
|
31
|
-
function
|
|
31
|
+
hostHelpers.setupAdminPageRoute(params.router, '/admin/plugins/sso-facebook', function (req, res) {
|
|
32
32
|
res.render('admin/plugins/sso-facebook', {
|
|
33
33
|
baseUrl: nconf.get('url'),
|
|
34
34
|
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
params.router.get('/admin/plugins/sso-facebook', params.middleware.admin.buildHeader, render);
|
|
38
|
-
params.router.get('/api/admin/plugins/sso-facebook', render);
|
|
35
|
+
});
|
|
39
36
|
|
|
40
|
-
hostHelpers.setupPageRoute(params.router, '/deauth/facebook',
|
|
37
|
+
hostHelpers.setupPageRoute(params.router, '/deauth/facebook', [params.middleware.requireUser], function (req, res) {
|
|
41
38
|
res.render('plugins/sso-facebook/deauth', {
|
|
42
39
|
service: "Facebook",
|
|
43
40
|
});
|
|
@@ -227,6 +224,7 @@
|
|
|
227
224
|
|
|
228
225
|
Facebook.login = function (fbid, name, email, picture, accessToken, refreshToken, profile, callback) {
|
|
229
226
|
winston.verbose("Facebook.login fbid, name, email, picture: " + fbid + ", " + name + ", " + email + ", " + picture);
|
|
227
|
+
const autoConfirm = Facebook.settings && Facebook.settings.autoconfirm === "on" ? 1 : 0;
|
|
230
228
|
|
|
231
229
|
Facebook.getUidByFbid(fbid, function (err, uid) {
|
|
232
230
|
if (err) {
|
|
@@ -242,14 +240,14 @@
|
|
|
242
240
|
});
|
|
243
241
|
} else {
|
|
244
242
|
// New User
|
|
245
|
-
var success =
|
|
243
|
+
var success = async (uid) => {
|
|
246
244
|
// Save facebook-specific information to the user
|
|
247
245
|
user.setUserField(uid, 'fbid', fbid);
|
|
248
246
|
db.setObjectField('fbid:uid', fbid, uid);
|
|
249
|
-
var autoConfirm = Facebook.settings && Facebook.settings.autoconfirm === "on" ? 1 : 0;
|
|
250
247
|
|
|
251
248
|
if (autoConfirm) {
|
|
252
|
-
user.
|
|
249
|
+
await user.setUserField(uid, 'email', email);
|
|
250
|
+
await user.email.confirmByUid(uid);
|
|
253
251
|
}
|
|
254
252
|
|
|
255
253
|
// Save their photo, if present
|
|
@@ -276,7 +274,7 @@
|
|
|
276
274
|
return callback(new Error('[[error:sso-registration-disabled, Facebook]]'));
|
|
277
275
|
}
|
|
278
276
|
|
|
279
|
-
user.create({ username: name, email: email }, function (err, uid) {
|
|
277
|
+
user.create({ username: name, email: !autoConfirm ? email : undefined }, function (err, uid) {
|
|
280
278
|
if (err) {
|
|
281
279
|
return callback(err);
|
|
282
280
|
}
|