-
-
Save aheuermann/0f603776db40ab087fa24741aa5d941c to your computer and use it in GitHub Desktop.
Revisions
-
aheuermann revised this gist
Mar 31, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,10 @@ function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (!user) { return {available: true}; } return facade.user.isUserAnInvitedTaker(user).chain(function (isInvited) { return isInvited ? {invited: true} : {available: false} }); }).chain(res.handler.successHandler(), res.handler.errorHandler(errors.UNKNOWN_ERROR)); } -
anshdivu revised this gist
Mar 31, 2016 . No changes.There are no files selected for viewing
-
anshdivu revised this gist
Mar 31, 2016 . No changes.There are no files selected for viewing
-
anshdivu revised this gist
Mar 30, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // https://github.com/C2FO/c2fo/blob/develop/api/lib/registration/routes.js#L50-L62 function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (user) { -
anshdivu revised this gist
Mar 30, 2016 . 1 changed file with 14 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,15 @@ function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (user) { return facade.user.isUserAnInvitedTaker(user).chain(function (isInvited) { if (isInvited) { res.handler.success({invited: true}); }else { res.handler.success({available: false}); } }); } else { res.handler.success({available: true}); } }, res.handler.errorHandler(errors.UNKNOWN_ERROR)); } -
anshdivu revised this gist
Mar 30, 2016 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (user) { return facade.user.isUserAnInvitedTaker(user).chain(function (isInvited) { if (isInvited) { res.handler.success({invited: true}); }else { res.handler.success({available: false}); } }); } else { res.handler.success({available: true}); } }, res.handler.errorHandler(errors.UNKNOWN_ERROR)); -
anshdivu revised this gist
Mar 30, 2016 . 2 changed files with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,9 +6,9 @@ function checkEmail(emailAddress) { if (!user) { return {available: true}; } else { return facade.user.isUserAnInvitedTaker(user).chain(function (isInvited) { return isInvited ? {invited: true} : {available: false} }); } }).chain(res.handler.successHandler(), res.handler.errorHandler(errors.UNKNOWN_ERROR)); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,14 +3,14 @@ // disadvantage - recovering from `not found` is explicit and has to occur in reject handler function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { return facade.user.isUserAnInvitedTaker(user).chain(function (isInvited) { return isInvited ? {invited: true} : {available: false}; }); }).chain(function(err) { if(err.objectNoFound()) { return {available: true}; } else { return comb.rejected(); } }).chain(res.handler.successHandler(), res.handler.errorHandler(errors.UNKNOWN_ERROR)); } -
anshdivu revised this gist
Mar 30, 2016 . No changes.There are no files selected for viewing
-
anshdivu revised this gist
Mar 30, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { return facade.user.isUserAnInvitedTaker(user); }, function(err) { if (err.objectNotFound()) { return {available: true}; } else { return comb.rejected(errors.UNKNOWN_ERROR); -
anshdivu revised this gist
Mar 30, 2016 . 2 changed files with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ // promise handles user not found by returing `null` // advantage - don't have to write a reject handler // disadvantage - possibly forget to write `null` check and cause null pointer exception function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (!user) { return {available: true}; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ // promise handles user not found by rejecting the promise and returning an error // advantage - success handler handles the common case and never causes a null pointer exception // disadvantage - recovering from `not found` is explicit and has to occur in reject handler function checkEmail(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { return facade.user.isUserAnInvitedTaker(user); }, function(err) { -
anshdivu created this gist
Mar 30, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ function checkEmail_withNull(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { if (!user) { return {available: true}; } else { return facade.user.isUserAnInvitedTaker(user); } }).chain(function (isInvited) { return isInvited ? {invited: true} : {available: false} }).chain(res.handler.successHandler(), res.handler.errorHandler(errors.UNKNOWN_ERROR)); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ function checkEmail_withReject(emailAddress) { return facade.user.getUserByEmailAddress(emailAddress).chain(function (user) { return facade.user.isUserAnInvitedTaker(user); }, function(err) { if (err.isNotFound()) { return {available: true}; } else { return comb.rejected(errors.UNKNOWN_ERROR); } }).chain(function (isInvited) { return isInvited ? {invited: true} : {available: false} }).chain(res.handler.successHandler(), res.handler.errorHandler()); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ function getUserByEmailAddress(email) { return User.first({emailAddress: email}).chain(function(user) { if (!user) { return ErrorPromises.NotFound(`No user found for emailAddress = ${email}`) } return user; }); }