質問

I have a JBoss Seam app that leverages Seam's IdentityManager and JpaIdentityStore components for handling user account creation and authentication. My components.xml file is setup correctly, and I'm able to use IdentityManager for creating accounts with no problem.

I have created a page to allow me to perform rudimentary account maintenance, such as enabling/disabling accounts. However, whenever I call the isUserEnabled(String username) method on IdentityManager, it always returns false. The corresponding method in JpaIdentityStore also returns false. Both occur even though I can see that the accounts have been enabled in the database. My user account class is annotated as follows:

@Name("user")
@Entity(name = "UserAccount")
@Table(name = "tbl_user_acct", uniqueConstraints = { @UniqueConstraint(columnNames = "username") })
public class UserAccountBean extends BaseDomainEntity implements
        VersionedDomainEntity {

    private static final long serialVersionUID = -3573332411594504888L;

    @UserEnabled
    private boolean enabled;

        ...

}

I don't have any issues with any of the other aspects of the IdentityManager class (changing passwords, creating/deleting accounts, etc.) The only error I run into is when I try to determine if a user is enabled or not. I don't receive any exceptions or error messages, I just get the wrong result returned.

Has anyone else encountered this? Any idea how best to start troubleshooting this issue?

EDIT: Some additional info...

I notice that when I call disableUser(String username), I do actually see the database reflect that in the ENABLED column. Additionally, when I call enableUser(String username), I immediately see that the account is enabled. However, if I navigate to another page and then come back and call isUserEnabled(), it still shows false.

役に立ちましたか?

解決

Turned out to be an issue related to lazy fetching. I have a UserProfile object with a userAccount property on it. The relation is Lazy-fetched. Once I changed it to Eager fetching, I received the appropriate response from isUserEnabled().

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top