jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r658414 - in /incubator/jspwiki/trunk: ChangeLog etc/i18n/CoreResources.properties etc/i18n/CoreResources_fi.properties src/webdocs/LostPassword.jsp src/webdocs/templates/default/LoginContent.jsp
Date Tue, 20 May 2008 20:34:00 GMT
Author: jalkanen
Date: Tue May 20 13:34:00 2008
New Revision: 658414

URL: http://svn.apache.org/viewvc?rev=658414&view=rev
Log:
JSPWIKI-151: If sending a password succeeds, no longer reports as an error.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/etc/i18n/CoreResources.properties
    incubator/jspwiki/trunk/etc/i18n/CoreResources_fi.properties
    incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp
    incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=658414&r1=658413&r2=658414&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue May 20 13:34:00 2008
@@ -11,6 +11,9 @@
         Added new i18n key in CoreResources, updated English and Finnish:
         
            * common.unknownauthor
+           
+        * [JSPWIKI-151]: If sending a password succeeds, it is no longer reported
+        as an error.
         
 2007-05-18  Dirk Frederickx <dirk.frederickx@gmail.com>
 

Modified: incubator/jspwiki/trunk/etc/i18n/CoreResources.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/i18n/CoreResources.properties?rev=658414&r1=658413&r2=658414&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/i18n/CoreResources.properties (original)
+++ incubator/jspwiki/trunk/etc/i18n/CoreResources.properties Tue May 20 13:34:00 2008
@@ -67,7 +67,7 @@
 lostpwd.newpassword.email=As requested, your new password for login "{0}" is "{1}" \
                     \n\nYou may log in at {2}.\n\n-- {3}
 lostpwd.newpassword.subject=New password for {0}
-lostpwd.nouser=No user or email &#39;{0}&#39; was found.
+lostpwd.nouser=No user or email "{0}" was found.
 lostpwd.nomail=Internal error: couldn't send the email!  Contact the site administrator,
please.
 lostpwd.emailed=A new password has been emailed to the requested account.
 

Modified: incubator/jspwiki/trunk/etc/i18n/CoreResources_fi.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/i18n/CoreResources_fi.properties?rev=658414&r1=658413&r2=658414&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/i18n/CoreResources_fi.properties (original)
+++ incubator/jspwiki/trunk/etc/i18n/CoreResources_fi.properties Tue May 20 13:34:00 2008
@@ -52,7 +52,7 @@
 lostpwd.newpassword.email=Uusi salasanasi tunnukselle "{0}" on "{1}" \
                     \n\nVoit käyttää sitä menemällä osoitteeseen {2}.\n\n-- Terveisin,
{3}
 lostpwd.newpassword.subject={0}: Uusi salasanasi
-lostpwd.nouser=Käyttäjää tai sähköpostiosoitetta &#39;{0}&#39; ei löydetty.
+lostpwd.nouser=Käyttäjää tai sähköpostiosoitetta "{0}" ei löydetty.
 lostpwd.nomail=Järjestelmävirhe: en voinut lähettää sähköpostia.  Olisitko niin kiltti,
että ilmoittaisit asiasta ylläpidolle?
 lostpwd.emailed=Uusi salasana on lähetetty sähköpostitse.
 

Modified: incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp?rev=658414&r1=658413&r2=658414&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp Tue May 20 13:34:00 2008
@@ -1,142 +1,135 @@
-<%@ page import="org.apache.log4j.*" %>
-<%@ page import="com.ecyrd.jspwiki.*" %>
-<%@ page import="java.util.*" %>
-<%@ page import="java.text.*" %>
-<%@ page import="javax.mail.*" %>
-<%@ page import="com.ecyrd.jspwiki.auth.user.*" %>
-<%@ page import="com.ecyrd.jspwiki.auth.*" %>
-<%@ page import="com.ecyrd.jspwiki.util.*" %>
-<%@ page import="com.ecyrd.jspwiki.i18n.*" %>
-<%@ page errorPage="/Error.jsp" %>
-<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
-<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase" %>
-<%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
-<%!
-    Logger log = Logger.getLogger("JSPWiki");
+<%@ page import="org.apache.log4j.*"%>
+<%@ page import="com.ecyrd.jspwiki.*"%>
+<%@ page import="java.util.*"%>
+<%@ page import="java.text.*"%>
+<%@ page import="javax.mail.*"%>
+<%@ page import="com.ecyrd.jspwiki.auth.user.*"%>
+<%@ page import="com.ecyrd.jspwiki.auth.*"%>
+<%@ page import="com.ecyrd.jspwiki.util.*"%>
+<%@ page import="com.ecyrd.jspwiki.i18n.*"%>
+<%@ page errorPage="/Error.jsp"%>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki"%>
+<%@ page import="com.ecyrd.jspwiki.tags.WikiTagBase"%>
+<%@ page import="javax.servlet.jsp.jstl.fmt.*"%>
+<%!Logger log = Logger.getLogger( "JSPWiki" );
 
     String message = null;
-    public boolean resetPassword(WikiEngine wiki, HttpServletRequest request, ResourceBundle
rb )
+
+    public boolean resetPassword( WikiEngine wiki, HttpServletRequest request, ResourceBundle
rb )
     {
         // Reset pw for account name
-        String name = request.getParameter("name");
+        String name = request.getParameter( "name" );
         UserDatabase userDatabase = wiki.getUserManager().getUserDatabase();
         boolean success = false;
 
         try
         {
             UserProfile profile = null;
-/*
-// This is disabled because it would otherwise be possible to DOS JSPWiki instances
-// by requesting new passwords for all users.  See https://issues.apache.org/jira/browse/JSPWIKI-78
-            try
-            {
-                profile = userDatabase.find(name);
-            }
-            catch (NoSuchPrincipalException e)
-            {
-                // Try email as well
-            }
- */
+            /*
+             // This is disabled because it would otherwise be possible to DOS JSPWiki instances
+             // by requesting new passwords for all users.  See https://issues.apache.org/jira/browse/JSPWIKI-78
+             try
+             {
+             profile = userDatabase.find(name);
+             }
+             catch (NoSuchPrincipalException e)
+             {
+             // Try email as well
+             }
+             */
             if( profile == null )
             {
-                profile = userDatabase.findByEmail(name);
+                profile = userDatabase.findByEmail( name );
             }
- 
-			String email = profile.getEmail();
 
-			String randomPassword = TextUtil.generateRandomPassword();
+            String email = profile.getEmail();
 
-			// Try sending email first, as that is more likely to fail.
+            String randomPassword = TextUtil.generateRandomPassword();
 
-            Object[] args = { profile.getLoginName(),
-                             randomPassword,
-                             wiki.getURLConstructor().makeURL(WikiContext.NONE, "Login.jsp",
true, ""),
-                             wiki.getApplicationName()
-            };
+            // Try sending email first, as that is more likely to fail.
 
-            String mailMessage = MessageFormat.format( rb.getString("lostpwd.newpassword.email"),
args );
+            Object[] args = { profile.getLoginName(), randomPassword,
+                             wiki.getURLConstructor().makeURL( WikiContext.NONE, "Login.jsp",
true, "" ), wiki.getApplicationName() };
+
+            String mailMessage = MessageFormat.format( rb.getString( "lostpwd.newpassword.email"
), args );
 
             Object[] args2 = { wiki.getApplicationName() };
- 			MailUtil.sendMessage( wiki,
-                                  email,
- 			                      MessageFormat.format( rb.getString("lostpwd.newpassword.subject"),
args2),
- 			                      mailMessage );
-
-            log.info("User "+email+" requested and received a new password.");
-
-			// Mail succeeded.  Now reset the password.
-			// If this fails, we're kind of screwed, because we already emailed.
-			profile.setPassword(randomPassword);
-			userDatabase.save(profile);
-			userDatabase.commit();
-			success = true;
+            MailUtil.sendMessage( wiki, email, MessageFormat.format( rb.getString( "lostpwd.newpassword.subject"
), args2 ),
+                                  mailMessage );
+
+            log.info( "User " + email + " requested and received a new password." );
+
+            // Mail succeeded.  Now reset the password.
+            // If this fails, we're kind of screwed, because we already emailed.
+            profile.setPassword( randomPassword );
+            userDatabase.save( profile );
+            userDatabase.commit();
+            success = true;
         }
-        catch (NoSuchPrincipalException e)
+        catch( NoSuchPrincipalException e )
         {
             Object[] args = { name };
-            message = MessageFormat.format( rb.getString("lostpwd.nouser"), args );
-            log.info("Tried to reset password for non-existent user '" + name + "'");
+            message = MessageFormat.format( rb.getString( "lostpwd.nouser" ), args );
+            log.info( "Tried to reset password for non-existent user '" + name + "'" );
         }
-        catch (SendFailedException e)
+        catch( SendFailedException e )
         {
-            message = rb.getString("lostpwd.nomail");
-            log.error("Tried to reset password and got SendFailedException: " + e);
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got SendFailedException: " + e );
         }
-        catch (AuthenticationFailedException e)
+        catch( AuthenticationFailedException e )
         {
-            message = rb.getString("lostpwd.nomail");
-            log.error("Tried to reset password and got AuthenticationFailedException: " +
e);
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got AuthenticationFailedException: "
+ e );
         }
-        catch (Exception e)
+        catch( Exception e )
         {
-            message = rb.getString("lostpwd.nomail");
-            log.error("Tried to reset password and got another exception: " + e);
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got another exception: " + e );
         }
         return success;
-    }
-%>
+    }%>
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
 
-	//Create wiki context like in Login.jsp:
+    //Create wiki context like in Login.jsp:
     //don't check for access permissions: if you have lost your password you cannot login!
-	WikiContext wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
PageContext.REQUEST_SCOPE );
+    WikiContext wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
PageContext.REQUEST_SCOPE );
 
-	// If no context, it means we're using container auth.  So, create one anyway
-	if( wikiContext == null )
-	{
-	    wikiContext = wiki.createContext( request, WikiContext.LOGIN ); /* reuse login context
! */
-	    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
-	                              wikiContext,
-	                              PageContext.REQUEST_SCOPE );
-	}
+    // If no context, it means we're using container auth.  So, create one anyway
+    if( wikiContext == null )
+    {
+        wikiContext = wiki.createContext( request, WikiContext.LOGIN ); /* reuse login context
! */
+        pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT, wikiContext, PageContext.REQUEST_SCOPE
);
+    }
 
-	ResourceBundle rb = wikiContext.getBundle("CoreResources");
+    ResourceBundle rb = wikiContext.getBundle( "CoreResources" );
 
     WikiSession wikiSession = wikiContext.getWikiSession();
-    String action  = request.getParameter("action");
+    String action = request.getParameter( "action" );
 
     boolean done = false;
 
-    if ((action != null) && (action.equals("resetPassword"))) {
-	    if ( resetPassword( wiki, request, rb ) ) {
-	        done = true;
-	        wikiSession.addMessage( "resetpw", rb.getString("lostpwd.emailed") );
-            pageContext.setAttribute("passwordreset","done");
-	    }
-	    else // Error
-	    {
-            wikiSession.addMessage( "resetpw", message);
-	    } 
+    if( (action != null) && (action.equals( "resetPassword" )) )
+    {
+        if( resetPassword( wiki, request, rb ) )
+        {
+            done = true;
+            wikiSession.addMessage( "resetpwok", rb.getString( "lostpwd.emailed" ) );
+            pageContext.setAttribute( "passwordreset", "done" );
+        }
+        else
+        // Error
+        {
+            wikiSession.addMessage( "resetpw", message );
+        }
     }
 
-    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    response.setContentType( "text/html; charset=" + wiki.getContentEncoding() );
     response.setHeader( "Cache-control", "max-age=0" );
     response.setDateHeader( "Expires", new Date().getTime() );
     response.setDateHeader( "Last-Modified", new Date().getTime() );
 
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );       
                                                    
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(),
"ViewTemplate.jsp" );
 %>
-<wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
+<wiki:Include page="<%=contentPage%>" />

Modified: incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp?rev=658414&r1=658413&r2=658414&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp Tue May 20 13:34:00
2008
@@ -131,6 +131,7 @@
       <td colspan="2" class="formhelp">
         <wiki:Messages div="error" topic="resetpw"
                     prefix='<%=LocaleSupport.getLocalizedMessage(pageContext,"login.errorprefix")%>'
/>
+        <wiki:Messages div="information" topic="resetpwok" />
       </td>
     </tr>
     </c:if>



Mime
View raw message