Seam - IdentityManager.isUserEnabled() 的问题
我有一个 JBoss Seam 应用程序,它利用 Seam 的 IdentityManager
和 JpaIdentityStore
组件来处理用户帐户创建和身份验证。我的 components.xml
文件设置正确,并且我可以使用 IdentityManager
创建帐户,没有任何问题。
我创建了一个页面来执行基本的帐户维护,例如启用/禁用帐户。但是,每当我在 IdentityManager
上调用 isUserEnabled(String username)
方法时,它总是返回 false。 JpaIdentityStore
中的相应方法也返回 false。即使我可以看到数据库中已启用帐户,这两种情况都会发生。我的用户帐户类注释如下:
@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;
...
}
我对 IdentityManager
类的任何其他方面都没有任何问题(更改密码、创建/删除帐户等) 我运行的唯一错误into 是当我尝试确定用户是否启用时。我没有收到任何异常或错误消息,我只是返回了错误的结果。
还有其他人遇到过这种情况吗?知道如何最好地开始解决此问题吗?
编辑:一些附加信息...
我注意到,当我调用 disableUser(String username)
时,我实际上看到数据库在 ENABLED 列中反映了这一点。此外,当我调用 enableUser(String username)
时,我立即看到该帐户已启用。但是,如果我导航到另一个页面然后返回并调用 isUserEnabled(),它仍然显示 false。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原来是与延迟获取相关的问题。我有一个 UserProfile 对象,上面有一个 userAccount 属性。该关系是惰性获取的。当我将其更改为急切获取时,我收到了来自 isUserEnabled() 的适当响应。
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().