Skip to content

Commit

Permalink
🎨 optimise public client registration error handling (#7992)
Browse files Browse the repository at this point in the history
no issue
- auth.init happens in background and if an error occurs, Ghost will log this error to stdout/file
- do not double create Ignition error
- update passport-ghost to handle a none response from the auth service (e.g. wrong auth url), see TryGhost/passport-ghost@123da4d
  • Loading branch information
kirrg001 authored and kevinansfield committed Feb 14, 2017
1 parent ead92cb commit 4f3f01e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions core/server/auth/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,25 @@ exports.init = function initPassport(options) {
_private.registerEvents();
return resolve({passport: passport.initialize()});
}).catch(function onError(err) {
debug('Public registration failed:' + err.message);

// @TODO: see https://github.com/TryGhost/Ghost/issues/7627
// CASE: can happen if database query fails
if (_.isArray(err)) {
err = err[0];
}

debug('Public registration failed:' + err.message);
if (!errors.utils.isIgnitionError(err)) {
err = new errors.GhostError({
err: err
});
}

err.level = 'critical';
err.context = err.context || 'Public client registration failed';
err.help = err.help || 'Please verify the configured url: ' + ghostOAuth2Strategy.url;

return reject(new errors.GhostError({
err: err,
context: 'Public client registration failed',
help: 'Please verify the configured url: ' + ghostOAuth2Strategy.url
}));
return reject(err);
});
});
};

0 comments on commit 4f3f01e

Please sign in to comment.