[opencms-dev] Forgot Password functionality

Patricio Keilty opencms at colaborativa.net
Wed Mar 23 17:26:24 CET 2005


Thanks for your reply Frans.

It worked when previewing from workplace, but when accessing the site 
online, i get

org.opencms.security.CmsSecurityException: 
[org.opencms.db.CmsSecurityManager] writeUser() customera [Code 300 - 
Administrator priviledges are required to perform this operation]

As suggested in related thread i should login with admin privileges, 
make changes and then invalidate session, is this correct?

Any hint on how to retrieve a CmsUser based on email?

Regards,
Patricio

Patricio Keilty
Colaborativa.net



Frans Postma wrote:

>I think you need to add something like this as last line:
>
>
>    cmso.writeUser(user);
>
>== javadoc:
>
>writeUser
>
>public void writeUser(CmsUser user)
>               throws CmsException
>Updates the user information. 
>
>The user id has to be a valid OpenCms user id.
>The user with the given id will be completely overriden by the given data.
>
>Parameters:
>user - the user to be written 
>Throws: 
>CmsException - if operation was not successful
>==
>
>Frans
>
>  
>
>>-----Original Message-----
>>From: opencms-dev-bounces at opencms.org 
>>[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Patricio Keilty
>>Sent: woensdag 23 maart 2005 0:40
>>To: The OpenCms mailing list
>>Subject: [opencms-dev] Forgot Password functionality
>>
>>Hi,
>>i need to provide Forgot Password functionality for our 
>>extranet, so in 
>>case a customer has forgotten its username or pass, can enter 
>>his email 
>>and get its user & new pass emailed. So, user data needs to 
>>be retrieved 
>>by email, generate a random password & update user data; then 
>>user/pass 
>>will be mailed back to the customer.
>>Have found a similar thread but with different requirements in 
>>http://mail.opencms.org/pipermail/opencms-dev/2004q4/014262.html. 
>><http://mail.opencms.org/pipermail/opencms-dev/2004q4/014262.html>
>>I plan to employ a jsp like the following:
>>
>><%
>>    CmsJspActionElement cms = new CmsJspActionElement( pageContext, 
>>request, response );
>>    CmsObject cmso = cms.getCmsObject();
>>
>>    String returnEmail = request.getParameter( "email" );
>>    String userName = request.getParameter( "username" );
>>    String redirect = request.getParameter( "redirect" );
>>
>>    try {
>>
>>        // retrieve user by email?
>>        CmsUser user = cmso.readUser( userName );
>>        String userEmail = user.getEmail();
>>        if( userEmail != null && !userEmail.equals(  returnEmail )){
>>             // email does not match
>>        } else {
>>            // create new random password
>>            String newPass = "aabbcc";
>>
>>            user.setPassword( newPass );
>>            user.touch();
>>        }
>>    } catch( CmsException e ){
>>        // user not found
>>    }
>>
>>    response.sendRedirect( redirect );
>>%>
>>
>>Is it possible to retrieve user data by email?
>>Have tried to change user password using 
>>CmsUser.setPassword(), but it 
>>did not update user pass.
>>
>>Could someone please provide sample code or any hints to 
>>achieve these?
>>
>>Thanks in advance,
>>Patricio
>>
>>-- 
>>Patricio Keilty
>>Colaborativa.net
>>
>>
>>
>>_______________________________________________
>>This mail is send to you from the opencms-dev mailing list
>>To change your list options, or to unsubscribe from the list, 
>>please visit
>>http://mail.opencms.org/mailman/listinfo/opencms-dev
>>
>>    
>>
>
>
>  
>



More information about the opencms-dev mailing list