Created
March 15, 2016 12:45
-
-
Save wispborne/8856760a88a00113b00b 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
public void signIn(User user) { | |
api.signIn(user, onSuccessCallback: { | |
getLinks(user); | |
}, onErrorCallback(): { | |
reauthorize(user); | |
} | |
public void getLinks(User user) { | |
api.getLinks(user, onSuccessCallback: { | |
postSuccessEvent(); | |
}, onErrorCallback: { | |
if(user.hasName()) { | |
bus.post(ERROR_EVENT); | |
} else { | |
postSuccessEvent(); | |
} | |
}); | |
} | |
private void reauthorize(User user) { | |
api.reauthorize(user, onSuccessCallback: { | |
signInUser(user); | |
}, onErrorCallback: { | |
bus.post(INVALID_CREDENTIALS_EVENT); | |
} | |
} | |
private void postSuccessEvent() { | |
if(isSignInFlow()) { | |
bus.post(SIGN_IN_SUCCESS_EVENT); | |
} else if(isRegisterFlow()) { | |
bus.post(REGISTER_SUCCESS_EVENT); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment