@@ -13,6 +13,7 @@ var async = require('async');
1313var _ = require ( 'underscore' ) ;
1414var BadRequestError = require ( '../errors/BadRequestError' ) ;
1515var ForbiddenError = require ( '../errors/ForbiddenError' ) ;
16+ var NotFoundError = require ( '../errors/NotFoundError' ) ;
1617var UnauthorizedError = require ( '../errors/UnauthorizedError' ) ;
1718var IllegalArgumentError = require ( '../errors/IllegalArgumentError' ) ;
1819
@@ -278,6 +279,8 @@ function getUserIdentity(api, connection, next) {
278279 api . dataAccess . executeQuery ( 'get_user_email_and_handle' , { userId : caller . userId } , dbConnectionMap , cb ) ;
279280 } ,
280281 function ( rs , cb ) {
282+ api . helper . handleError ( api , connection , err ) ;
283+ next ( connection , true ) ;
281284 response = {
282285 uid : caller . userId ,
283286 handle : rs [ 0 ] . handle ,
@@ -334,27 +337,33 @@ function getUserIdentityByAuth0Id(api, connection, next) {
334337 var helper = api . helper ,
335338 auth0id = connection . params . id ,
336339 userid = 0 ,
337- dbConnectionMap = connection . dbConnectionMap ,
340+ dbConnectionMap = connection . dbConnectionMap ,
341+ notfound = new NotFoundError ( 'Feelin lucky, punk?' ) ,
338342 response ;
339343
340344 async . waterfall ( [
341345 function ( cb ) {
342- var splits = auth0id . split ( '|' ) ;
343- if ( splits [ 0 ] == 'ad' ) {
344- cb ( null , [ { user_id : Number ( splits [ 1 ] ) } ] ) ;
345- } else {
346- api . helper . getProviderId ( splits [ 0 ] , function ( err , provider ) {
347- if ( err ) {
348- cb ( err ) ;
349- } else {
350- api . dataAccess . executeQuery ( "get_user_by_social_login" ,
351- {
352- social_user_id : splits [ 1 ] ,
353- provider_id : provider
354- } ,
355- dbConnectionMap , cb ) ;
356- }
357- } ) ;
346+ try {
347+ var splits = auth0id . split ( '|' ) ;
348+ if ( splits [ 0 ] == 'ad' ) {
349+ cb ( null , [ { user_id : Number ( splits [ 1 ] ) } ] ) ;
350+ } else {
351+ api . helper . getProviderId ( splits [ 0 ] , function ( err , provider ) {
352+ if ( err ) {
353+ cb ( notfound ) ;
354+ } else {
355+ api . dataAccess . executeQuery ( "get_user_by_social_login" ,
356+ {
357+ social_user_id : splits [ 1 ] ,
358+ provider_id : provider
359+ } ,
360+ dbConnectionMap , cb ) ;
361+ }
362+ } ) ;
363+ }
364+ }
365+ catch ( exc ) {
366+ cb ( notfound ) ;
358367 }
359368 } ,
360369 function ( result , cb ) {
0 commit comments