if (StringUtils.isBlank(verifier))
return renderInvalid(UserErrorCode.INVALID_OAUTH_VERIFIER);
String sessionId = session().get(Constants.Session.ID_KEY);
assert sessionId != null;
TwitterLoginInformation loginInformation =
(TwitterLoginInformation) Cache.get(Constants.Cache.TWITTER_LOGIN_KEY_PREFIX + sessionId);
if (loginInformation == null)
return renderInvalid(UserErrorCode.UNEXPECTED_REQUEST);
Cache.set(Constants.Cache.TWITTER_LOGIN_KEY_PREFIX + sessionId, null);
MessageCode messageCode = null;
try {
ITwitterService twitterService = PartakeApp.getTwitterService();
UserTwitterLink linkage = twitterService.createTwitterLinkageFromLoginInformation(loginInformation, verifier);
UserEx user = new VerifyForTwitterActionTransaction(linkage).execute();
session().put(Constants.Session.USER_ID_KEY, user.getId());
messageCode = MessageCode.MESSAGE_AUTH_LOGIN;
} catch (TwitterException e) {
return renderError(ServerErrorCode.TWITTER_OAUTH_ERROR, e);
}
String redirectURL = loginInformation.getRedirectURL();
if (StringUtils.isEmpty(redirectURL))
return renderRedirect("/", messageCode);
// If the redirect page is the error page, we do not want to show it. Showing the top page is better.
// TODO(mayah): We should not put these values here.