Did you first call to WL.Client.updateUserInfo();
?
From the documentation:
updateUserInfo(options)
This method refreshes user data after an exception. Use this method when the application receives an exception after calling the invokeProcedure() method. The method refreshes the data for the following methods:
WL.Client.getUserName(realm)
WL.Client.getLoginName(realm)
WL.Client.isUserAuthenticated(realm)After such an exception, you can verify the user authentication status by calling this function first, and then the isUserAuthenticated() method.
Parameters: options - Optional. A standard options object.