Is it a good idea to use a class/seam component that extends an EntityQuery when checking for user and password credentials?
Inside the authenticator component I have created a Seam Component that extends EntityQuery which checks if the user and password is valid on a USER table:
try{ .... User theuser= (User)userQuery.getSingleResult(); ... ... } catch {PersistenceException pe) { facesMessage.add("Invalid Username/Password"); }
Problem with this code is the scenario when the first login attempt is invalid, I can't retry my login anymore as the 2nd attempt will now issue an Exception saying that there is no Tranasction open
Or shhould i just use a Session Bean instead of the EntityQuery?
Read the seam doc on chapter 13.4. Authentication
There it says how you can do this