Add friendly error message on auth create attemp

This commit is contained in:
Berkeley Martinez
2016-05-02 22:26:18 -07:00
parent 8166bfbcd8
commit 7b8dc2e77e
2 changed files with 10 additions and 8 deletions

View File

@ -15,6 +15,8 @@ const debug = debugFactory('fcc:models:userIdent');
export default function(UserIdent) {
// original source
// github.com/strongloop/loopback-component-passport
const createAccountMessage =
'Accounts can only be created using GitHub or though email';
UserIdent.login = function(
provider,
authScheme,
@ -71,11 +73,11 @@ export default function(UserIdent) {
const userObj = options.profileToUser(provider, profile, options);
if (getSocialProvider(provider) !== 'github') {
return process.nextTick(() => cb(
new Error(
'accounts can only be created using Github or though email'
)
));
const err = new Error(createAccountMessage);
err.userMessage = createAccountMessage;
err.messageType = 'info';
err.redirectTo = '/signin';
return process.nextTick(() => cb(err));
}
let query;