-
-
Save aheuermann/0f603776db40ab087fa24741aa5d941c to your computer and use it in GitHub Desktop.
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 characters
| 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 characters
| 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 characters
| function getUserByEmailAddress(email) { | |
| return User.first({emailAddress: email}).chain(function(user) { | |
| if (!user) { | |
| return ErrorPromises.NotFound(`No user found for emailAddress = ${email}`) | |
| } | |
| return user; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment