nodebb-plugin-sso-github 3.0.4 → 3.1.1

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 CHANGED
@@ -209,6 +209,7 @@
209
209
 
210
210
  hostHelpers.setupAdminPageRoute(data.router, '/admin/plugins/sso-github', function (req, res) {
211
211
  res.render('admin/plugins/sso-github', {
212
+ title: constants.name,
212
213
  callbackURL: nconf.get('url') + '/auth/github/callback'
213
214
  });
214
215
  });
@@ -218,37 +219,23 @@
218
219
  service: "GitHub",
219
220
  });
220
221
  });
221
- data.router.post('/deauth/github', [data.middleware.requireUser, data.middleware.applyCSRF], function (req, res, next) {
222
- GitHub.deleteUserData({
222
+ data.router.post('/deauth/github', [data.middleware.requireUser, data.middleware.applyCSRF], hostHelpers.tryRoute(async function (req, res) {
223
+ await GitHub.deleteUserData({
223
224
  uid: req.user.uid,
224
- }, function (err) {
225
- if (err) {
226
- return next(err);
227
- }
228
-
229
- res.redirect(nconf.get('relative_path') + '/me/edit');
230
225
  });
231
- });
226
+ res.redirect(nconf.get('relative_path') + '/me/edit');
227
+ }));
232
228
 
233
229
  callback();
234
230
  };
235
231
 
236
- GitHub.deleteUserData = function(data, callback) {
237
- var uid = data.uid;
238
-
239
- async.waterfall([
240
- async.apply(User.getUserField, uid, 'githubid'),
241
- function(oAuthIdToDelete, next) {
242
- db.deleteObjectField('githubid:uid', oAuthIdToDelete, next);
243
- },
244
- async.apply(db.deleteObjectField, 'user:' + uid, 'githubid'),
245
- ], function(err) {
246
- if (err) {
247
- winston.error('[sso-github] Could not remove OAuthId data for uid ' + uid + '. Error: ' + err);
248
- return callback(err);
249
- }
250
- callback(null, uid);
251
- });
232
+ GitHub.deleteUserData = async function(data) {
233
+ const { uid } = data;
234
+ const githubid = await User.getUserField(uid, 'githubid');
235
+ if (githubid) {
236
+ await db.deleteObjectField('githubid:uid', oAuthIdToDelete, next);
237
+ await db.deleteObjectField('user:' + uid, 'githubid');
238
+ }
252
239
  };
253
240
 
254
241
  module.exports = GitHub;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-sso-github",
3
- "version": "3.0.4",
3
+ "version": "3.1.1",
4
4
  "description": "NodeBB GitHub SSO",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -46,6 +46,6 @@
46
46
  "passport-github2": "^0.1.9"
47
47
  },
48
48
  "nbbpm": {
49
- "compatibility": "^3.0.0"
49
+ "compatibility": "^4.0.0"
50
50
  }
51
51
  }
@@ -1,45 +1,46 @@
1
- <div class="row">
2
- <div class="col-sm-2 col-12 settings-header">GitHub SSO</div>
3
- <div class="col-sm-10 col-12">
4
- <div class="alert alert-info">
5
- Register a new <strong>GitHub Application</strong> via
6
- <a href="https://github.com/settings/developers">Developer Applications</a> and then paste your application details here.
7
- </div>
8
- <form class="sso-github-settings">
9
- <div class="mb-3">
10
- <label for="id">Client ID</label>
11
- <input type="text" name="id" title="Client ID" class="form-control" placeholder="Client ID">
12
- </div>
13
- <div class="mb-3">
14
- <label for="secret">Client Secret</label>
15
- <input type="text" name="secret" title="Client Secret" class="form-control" placeholder="Client Secret" />
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 px-0 mb-4" tabindex="0">
6
+ <div class="alert alert-info">
7
+ Register a new <strong>GitHub Application</strong> via
8
+ <a href="https://github.com/settings/developers">Developer Applications</a> and then paste your application details here.
16
9
  </div>
17
- <div class="mb-3 alert alert-warning">
18
- <label for="callback">Your NodeBB&apos;s "Authorization callback URL"</label>
19
- <input type="text" id="callback" title="Authorization callback URL" class="form-control" value="{callbackURL}" readonly />
10
+ <form class="sso-github-settings">
11
+ <div class="mb-3">
12
+ <label for="id">Client ID</label>
13
+ <input type="text" name="id" title="Client ID" class="form-control" placeholder="Client ID">
14
+ </div>
15
+ <div class="mb-3">
16
+ <label for="secret">Client Secret</label>
17
+ <input type="text" name="secret" title="Client Secret" class="form-control" placeholder="Client Secret" />
18
+ </div>
19
+ <div class="mb-3 alert alert-warning">
20
+ <label for="callback">Your NodeBB&apos;s "Authorization callback URL"</label>
21
+ <input type="text" id="callback" title="Authorization callback URL" class="form-control" value="{callbackURL}" readonly />
22
+ <p class="form-text">
23
+ Ensure that this value is set in your GitHub application&apos;s settings
24
+ </p>
25
+ </div>
26
+ <div class="form-check">
27
+ <input type="checkbox" class="form-check-input" id="disableRegistration" name="disableRegistration" />
28
+ <label for="disableRegistration" class="form-check-label">
29
+ Disable user registration via SSO
30
+ </label>
31
+ </div>
32
+ <div class="form-check">
33
+ <input type="checkbox" class="form-check-input" id="needToVerifyEmail" name="needToVerifyEmail" />
34
+ <label for="needToVerifyEmail" class="form-check-label">
35
+ Need user to verify email
36
+ </label>
37
+ </div>
20
38
  <p class="form-text">
21
- Ensure that this value is set in your GitHub application&apos;s settings
39
+ Restricting registration means that only registered users can associate their account with this SSO strategy.
40
+ This restriction is useful if you have uesrs bypassing registration controls by using social media accounts, or
41
+ if you wish to use the NodeBB registration queue.
22
42
  </p>
23
- </div>
24
- <div class="form-check">
25
- <input type="checkbox" class="form-check-input" id="disableRegistration" name="disableRegistration" />
26
- <label for="disableRegistration" class="form-check-label">
27
- Disable user registration via SSO
28
- </label>
29
- </div>
30
- <div class="form-check">
31
- <input type="checkbox" class="form-check-input" id="needToVerifyEmail" name="needToVerifyEmail" />
32
- <label for="needToVerifyEmail" class="form-check-label">
33
- Need user to verify email
34
- </label>
35
- </div>
36
- <p class="form-text">
37
- Restricting registration means that only registered users can associate their account with this SSO strategy.
38
- This restriction is useful if you have uesrs bypassing registration controls by using social media accounts, or
39
- if you wish to use the NodeBB registration queue.
40
- </p>
41
- </form>
43
+ </form>
44
+ </div>
42
45
  </div>
43
46
  </div>
44
-
45
- <!-- IMPORT admin/partials/save_button.tpl -->