fix(signup): signup auth (#15628)

* fix(models.user): Colocate all user methods

Moved user methods/extensions into one file. Tracked down `next method
called more than once` error and setting headers after their sent. Let
regular error handler handle api errors as well.

* feat(server.auth): Disable github account creation

We are no longer allowing account creation through github

* refactor(Auth): Move user identity link into models dir

* feat(Disable link account login): This removes the ability to use a linked account t

* feat(errorhandlers): Add opbeat, filter out handled error
This commit is contained in:
Berkeley Martinez
2017-07-13 11:39:07 -07:00
committed by mrugesh mohapatra
parent 7805d74ea7
commit 2fcd976700
17 changed files with 591 additions and 497 deletions

View File

@@ -1,5 +1,6 @@
import errorHandler from 'errorhandler';
import accepts from 'accepts';
import { unwrapHandledError } from '../utils/create-handled-error.js';
export default function prodErrorHandler() {
if (process.env.NODE_ENV === 'development') {
@@ -21,20 +22,24 @@ export default function prodErrorHandler() {
// parse res type
const accept = accepts(req);
const type = accept.type('html', 'json', 'text');
const handled = unwrapHandledError(err);
const message = 'Oops! Something went wrong. Please try again later';
const redirectTo = handled.redirectTo || '/map';
const message = handled.message ||
'Oops! Something went wrong. Please try again later';
if (type === 'html') {
if (typeof req.flash === 'function') {
req.flash(err.messageType || 'errors', {
msg: err.userMessage || message
});
req.flash(
handled.type || 'errors',
{ msg: message }
);
}
return res.redirect(err.redirectTo || '/map');
return res.redirect(redirectTo);
// json
} else if (type === 'json') {
res.setHeader('Content-Type', 'application/json');
return res.send({
message: message
message
});
// plain text
} else {