if (isExternalLogin() && !isNewUser() && isAccountEnabledAndActivated()) {
applyAuthentication();
}
// Get the authenticated account and credentials
HAccount authenticatedAccount = null;
HCredentials authenticatedCredentials = null;
String username = credentials.getUsername();
if (authType == AuthenticationType.OPENID) {
authenticatedCredentials =
credentialsDAO.findByUser(zanataOpenId.getAuthResult()
.getAuthenticatedId());
// on first Open Id login, there might not be any stored credentials
if (authenticatedCredentials != null) {
authenticatedAccount = authenticatedCredentials.getAccount();
}
} else {
authenticatedCredentials = credentialsDAO.findByUser(username);
authenticatedAccount = accountDAO.getByUsername(username);
}