@@ -134,12 +134,6 @@ function onBeforeInsert() {
134134 /* restrict the names */
135135 $ this ->dataRecord ['username ' ] = $ webdavuser_prefix . $ this ->dataRecord ['username ' ];
136136
137- /*
138- * We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule needs
139- */
140- $ hash = md5 ($ this ->dataRecord ["username " ] . ': ' . $ this ->dataRecord ["dir " ] . ': ' . $ this ->dataRecord ["password " ]);
141- $ this ->dataRecord ["password " ] = $ hash ;
142-
143137 /*
144138 * Get the data of the domain, owning the webdav user
145139 */
@@ -155,6 +149,14 @@ function onBeforeInsert() {
155149
156150 function onAfterInsert () {
157151 global $ app , $ conf ;
152+
153+ /*
154+ * We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule needs
155+ */
156+ $ hash = md5 ($ this ->dataRecord ["username " ] . ': ' . $ this ->dataRecord ["dir " ] . ': ' . $ this ->dataRecord ["password " ]);
157+ $ this ->dataRecord ["password " ] = $ hash ;
158+
159+ $ app ->db ->query ("UPDATE webdav_user SET password = ' " .$ this ->dataRecord ["password " ]."' WHERE webdav_user_id = " .$ this ->id );
158160 }
159161
160162 function onBeforeUpdate () {
@@ -168,22 +170,24 @@ function onBeforeUpdate() {
168170 $ this ->dataRecord ["username " ] = $ data ['username ' ];
169171 $ this ->dataRecord ["dir " ] = $ data ['dir ' ];
170172 $ this ->dataRecord ['username_prefix ' ] = $ data ['username_prefix ' ];
171- $ passwordOld = $ data ['password ' ];
173+ $ this ->dataRecord ['passwordOld ' ] = $ data ['password ' ];
174+
175+ parent ::onBeforeUpdate ();
176+ }
172177
178+ function onAfterUpdate () {
179+ global $ app , $ conf ;
180+
173181 /*
174182 * We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule
175183 * needs (only if the pwd is changed)
176184 */
177- if ((isset ($ this ->dataRecord ["password " ])) && ($ this ->dataRecord ["password " ] != '' ) && ($ this ->dataRecord ["password " ] != $ passwordOld )) {
185+ if ((isset ($ this ->dataRecord ["password " ])) && ($ this ->dataRecord ["password " ] != '' ) && ($ this ->dataRecord ["password " ] != $ this -> dataRecord [ ' passwordOld ' ] )) {
178186 $ hash = md5 ($ this ->dataRecord ["username " ] . ': ' . $ this ->dataRecord ["dir " ] . ': ' . $ this ->dataRecord ["password " ]);
179187 $ this ->dataRecord ["password " ] = $ hash ;
180188 }
181-
182- parent ::onBeforeUpdate ();
183- }
184-
185- function onAfterUpdate () {
186- global $ app , $ conf ;
189+
190+ $ app ->db ->query ("UPDATE webdav_user SET password = ' " .$ this ->dataRecord ["password " ]."' WHERE webdav_user_id = " .$ this ->id );
187191 }
188192
189193}
0 commit comments