[Yanel-commits] rev 50214 - public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/yaneluser

michi at wyona.com michi at wyona.com
Mon Jun 7 13:13:36 CEST 2010


Author: michi
Date: 2010-06-07 13:13:36 +0200 (Mon, 07 Jun 2010)
New Revision: 50214

Modified:
   public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/yaneluser/EditYanelUserProfileResource.java
Log:
update password finished

Modified: public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/yaneluser/EditYanelUserProfileResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/yaneluser/EditYanelUserProfileResource.java	2010-06-07 11:03:06 UTC (rev 50213)
+++ public/yanel/trunk/src/contributions/resources/yanel-user/src/java/org/wyona/yanel/impl/resources/yaneluser/EditYanelUserProfileResource.java	2010-06-07 11:13:36 UTC (rev 50214)
@@ -101,8 +101,6 @@
      */
     private void updatePassword(String oldPassword) {
         try {
-            String newPassword = getEnvironment().getRequest().getParameter("newPassword");
-            String newPasswordConfirmed = getEnvironment().getRequest().getParameter("newPasswordConfirmation");
             String userId = getUserId();
 
             if (!getRealm().getIdentityManager().getUserManager().getUser(userId).authenticate(oldPassword)) {
@@ -111,26 +109,20 @@
                 return;
             }
 
-/*
-            if (getRealm().getIdentityManager().getUserManager().getUser(userId).authenticate(
-                    oldPassword)) {
-                String plainPassword = request.getParameter("newPassword");
-                boolean confirmation = plainPassword.equals(request
-                        .getParameter("newPasswordConfirmation"));
-                if (confirmation && !plainPassword.equals("")) {
+            String newPassword = getEnvironment().getRequest().getParameter("newPassword");
+            String newPasswordConfirmed = getEnvironment().getRequest().getParameter("newPasswordConfirmation");
+            if (newPassword != null && !newPassword.equals("")) {
+                if (newPassword.equals(newPasswordConfirmed)) {
                     User user = getRealm().getIdentityManager().getUserManager().getUser(userId);
-                    user.setPassword(plainPassword);
+                    user.setPassword(newPassword);
                     user.save();
-
-                    transformer.setParameter("success", "Password updated successfully");
+                    setTransformerParameter("success", "Password updated successfully");
                 } else {
-                    transformer.setParameter("error", "Either no new password was supplied "
-                            + "or the password supplied and its confirmation do not coincide");
+                    setTransformerParameter("error", "New password and its confirmation do not match!");
                 }
             } else {
-                transformer.setParameter("error", "Authentication failed!");
+                setTransformerParameter("error", "No new password was specified!");
             }
-*/
         } catch (Exception e) {
             log.error(e, e);
         }



More information about the Yanel-commits mailing list