This content has been marked as final.
Show 4 replies
-
1. Re: Access UserModule from a portlet when not authenticated
indyjones Aug 3, 2007 10:24 AM (in response to indyjones)Here is the code....
User test = userModule.findUserByUserName("admin");
Here is the errorjava.lang.ClassCastException: org.hibernate.hql.ast.HqlToken cannot be cast to org.hibernate.hql.ast.HqlToken
I do not get that error running the exact same code when the user is authenticated...
Any ideas?
Thanks
Indy -
2. Re: Access UserModule from a portlet when not authenticated
indyjones Aug 3, 2007 10:32 AM (in response to indyjones)ok...i get the userModule the following way...
userModule = (UserModule) new InitialContext().lookup("java:portal/UserModule");
Thanks
indy -
3. Re: Access UserModule from a portlet when not authenticated
indyjones Aug 3, 2007 11:14 AM (in response to indyjones)ok...got it to work...here is how I did it using JSF...
Get the userModule through JNDIuserModule = (UserModule) new InitialContext().lookup("java:portal/UserModule");
Get the user by using its user id....NOT user name....
DO THISUser test = userModule.findUserById(id);
DO NOT DO THISUser test = userModule.findUserByUserName("admin");
I basically wrote a simple Hibernate service layer to get the user id after a email is given and the answer to the secret question is correct.
Then, create a new password and change ittest.updatePassword(newpassword);
Then fire an email off to the user with their new password. I used ...Session session = (Session) new InitialContext().lookup("java:Mail");
That is configured through the deploy/mail-service.xml file. The Forums Portlet uses the same service
POOF! I now have a self managed user password system...AKA..."Forgot My Password" link
Indy -
4. Re: Access UserModule from a portlet when not authenticated
indyjones Aug 8, 2007 4:17 PM (in response to indyjones)The reason I was getting the Hibernate error was because of conflicts with my web apps Hibernate3.jar and the one in default/lib