loginUser = getUserService()
.merge(newUser, oldUser);
} else {
// Account auto merging is disabled - forward user
// to merge request page
final Call c = getResolver().askMerge();
if (c == null) {
throw new RuntimeException(
Messages.get(
"playauthenticate.core.exception.merge.controller_undefined",
SETTING_KEY_ACCOUNT_AUTO_MERGE));
}
storeMergeUser(newUser, session);
return Controller.redirect(c);
}
} else {
// the currently logged in user and the new login belong
// to the same local user,
// or Account merge is disabled, so just change the log
// in to the new user
loginUser = newUser;
}
} else if (!isLoggedIn) {
// 3. -> Signup
loginUser = signupUser(newUser, session, ap);
} else {
// !isLinked && isLoggedIn:
// 4. -> Link additional
if (isAccountAutoLink()) {
// Account auto linking is enabled
loginUser = getUserService().link(oldUser, newUser);
} else {
// Account auto linking is disabled - forward user to
// link suggestion page
final Call c = getResolver().askLink();
if (c == null) {
throw new RuntimeException(
Messages.get(
"playauthenticate.core.exception.link.controller_undefined",
SETTING_KEY_ACCOUNT_AUTO_LINK));
}
storeLinkUser(newUser, session);
return Controller.redirect(c);
}
}
return loginAndRedirect(context, loginUser);
} else {
return Controller.internalServerError(Messages
.get("playauthenticate.core.exception.general"));
}
} catch (final AuthException e) {
final Call c = getResolver().onException(e);
if (c != null) {
return Controller.redirect(c);
} else {
final String message = e.getMessage();
if (message != null) {