diff --git a/zanata-war/src/main/java/org/zanata/action/AuthenticationEvents.java b/zanata-war/src/main/java/org/zanata/action/AuthenticationEvents.java index 50f77f7cc0..cbe0e7fbe5 100644 --- a/zanata-war/src/main/java/org/zanata/action/AuthenticationEvents.java +++ b/zanata-war/src/main/java/org/zanata/action/AuthenticationEvents.java @@ -29,6 +29,7 @@ import javax.faces.application.FacesMessage; import javax.inject.Inject; +import org.apache.commons.lang.StringUtils; import org.apache.deltaspike.core.api.scope.WindowScoped; import org.apache.deltaspike.core.util.ContextUtils; import org.zanata.events.AlreadyLoggedInEvent; @@ -55,10 +56,12 @@ public void createSuccessful(@Observes UserCreatedEvent userCreatedEvent) { } public void loginInSuccessful(@Observes LoginSuccessfulEvent event) { - log.debug("Account logged in successfully"); - if (ContextUtils.isContextActive(WindowScoped.class)) { - facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO, - "authentication.loginSuccessful", event.getName()); + if (StringUtils.isNotBlank(event.getName())) { + log.debug("Account logged in successfully"); + if (ContextUtils.isContextActive(WindowScoped.class)) { + facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO, + "authentication.loginSuccessful", event.getName()); + } } } diff --git a/zanata-war/src/main/java/org/zanata/security/ZanataIdentity.java b/zanata-war/src/main/java/org/zanata/security/ZanataIdentity.java index 26073b49cc..08fec3193a 100644 --- a/zanata-war/src/main/java/org/zanata/security/ZanataIdentity.java +++ b/zanata-war/src/main/java/org/zanata/security/ZanataIdentity.java @@ -614,12 +614,15 @@ private void cacheUserDetails() { if (cachedPersonName == null) { HAccount account = accountDAO.getByUsername(cachedUsername); - HPerson person = account.getPerson(); - if (person != null) { - cachedPersonName = person.getName(); - cachedPersonEmail = person.getEmail(); + if (account != null) { + HPerson person = account.getPerson(); + if (person != null) { + cachedPersonName = person.getName(); + cachedPersonEmail = person.getEmail(); + } else { + cachedPersonEmail = null; + } } else { -// cachedPersonName = null; cachedPersonEmail = null; } }