[opencms-dev] Forgot Password functionality

Patricio Keilty opencms at colaborativa.net
Wed Mar 23 00:39:54 CET 2005


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




More information about the opencms-dev mailing list