Last active
March 4, 2016 18:44
-
-
Save petreboy14/e21981f066420585efa0 to your computer and use it in GitHub Desktop.
This file contains 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
create(params, cb) { | |
let sourcePromise = null; | |
if (params.provider === 'facebook') { | |
let options = { | |
sourceId: params.providerId, | |
source: params.provider, | |
token: params.oauth_token | |
}; | |
sourcePromise = this.methods.users.sources.getOne(options); | |
} else { | |
sourcePromise = SeqPromise.resolve(false); | |
} | |
return sourcePromise | |
.then((foundUser) => { | |
console.log(foundUser); | |
if (foundUser && foundUser.internal) { | |
params.foundUser = foundUser; | |
params.id = params.foundUser.id; | |
params.userId = params.foundUser.id; | |
return this.methods.users.createRedeem(params); | |
} else { | |
return this.methods.users.createNew(params); | |
} | |
}).nodeify(cb); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment