esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r908862 - in /incubator/esme/trunk/server/src/main: scala/org/apache/esme/lib/ProfileMgr.scala webapp/profile_view/edit.html
Date Thu, 11 Feb 2010 07:40:25 GMT
Author: vdichev
Date: Thu Feb 11 07:40:23 2010
New Revision: 908862

URL: http://svn.apache.org/viewvc?rev=908862&view=rev
Log:
ESME-105 Change password

Modified:
    incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
    incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html

Modified: incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala?rev=908862&r1=908861&r2=908862&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala (original)
+++ incubator/esme/trunk/server/src/main/scala/org/apache/esme/lib/ProfileMgr.scala Thu Feb
11 07:40:23 2010
@@ -67,6 +67,8 @@
                                  
       val openIdUrl = openID.map(_.authKey.is) getOrElse ""
       val from = "/profile_view/edit"
+
+      var pwd = ""
       
       def saveOpenID(openid: Box[Identifier], fo: Box[VerificationResult], exp: Box[Exception]):
LiftResponse = {
         (openid, exp) match {
@@ -100,6 +102,26 @@
         }
       }
       
+      // TODO: unify with duplicate validation code in UserAuth
+      def checkPassword(confirm: String) {
+        import UserPwdAuthModule.moduleName
+        
+        if (pwd != "") {
+          if (pwd != confirm) {
+            S.error(S.?("base_user_err_mismatch_password"))
+          } else if (pwd.length < 6) {
+            S.error(S.?("base_user_err_password_too_short"))
+          } else {
+            for (userPwd <- UserAuth.find(By(UserAuth.user, user),
+                                          By(UserAuth.authType, moduleName))) {
+              val salt = randomString(10)
+              val md5 = Helpers.md5(salt + pwd)
+              userPwd.authData(salt+";"+md5).save
+            }
+          }
+        }
+      }
+      
       bind("user", in, "nickname" -> text(user.nickname, {_ =>}, "disabled" -> "true"),
                        "lastName" -> user.lastName.toForm,
                        "imageURL" -> user.imageUrl.toForm,
@@ -107,6 +129,8 @@
                        "timezone" -> user.timezone.toForm,
                        "locale" -> user.locale.toForm,
                        "openid" -> text(openIdUrl, registerOpenID(_)),
+                       "password" -> password(pwd, p => pwd = p.trim),
+                       "confirm" -> password(pwd, p => checkPassword(p.trim)),
                        "save" -> submit("Save", user.save))
     }).getOrElse(NodeSeq.Empty)
 

Modified: incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html
URL: http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html?rev=908862&r1=908861&r2=908862&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html (original)
+++ incubator/esme/trunk/server/src/main/webapp/profile_view/edit.html Thu Feb 11 07:40:23
2010
@@ -27,6 +27,8 @@
         <tr> <td><lift:loc>ui_sign_up_timezone</lift:loc></td>
<td><user:timezone/></td> </tr>
         <tr> <td><lift:loc>ui_sign_up_locale</lift:loc></td>
<td><user:locale/></td> </tr>
         <tr> <td><lift:loc>ui_sign_up_openid</lift:loc></td>
<td><user:openid/></td> </tr>
+        <tr> <td><lift:loc>ui_login_password</lift:loc></td>
<td><user:password/></td> </tr>
+        <tr> <td><lift:loc>ui_login_password_repeat</lift:loc></td>
<td><user:confirm/></td> </tr>
         <user:save/>
       </tbody>
     </table>



Mime
View raw message