Skip to content

Commit 1302aa5

Browse files
committed
- No webdav users could be created because password validation failed.
1 parent 93fdfe3 commit 1302aa5

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

interface/web/sites/webdav_user_edit.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,6 @@ function onBeforeInsert() {
137137

138138
/* restrict the names */
139139
$this->dataRecord['username'] = $webdavuser_prefix . $this->dataRecord['username'];
140-
141-
/*
142-
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule needs
143-
*/
144-
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
145-
$this->dataRecord["password"] = $hash;
146140
}
147141

148142
parent::onBeforeInsert();
@@ -156,9 +150,16 @@ function onAfterInsert() {
156150

157151
// The webdav user shall be owned by the same group then the website
158152
$sys_groupid = $app->functions->intval($web['sys_groupid']);
159-
160-
$sql = "UPDATE webdav_user SET server_id = $server_id, sys_groupid = '$sys_groupid' WHERE webdav_user_id = ".$this->id;
153+
154+
/*
155+
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule needs
156+
*/
157+
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
158+
$this->dataRecord["password"] = $hash;
159+
160+
$sql = "UPDATE webdav_user SET server_id = ".$server_id.", sys_groupid = '".$sys_groupid."', password = '".$this->dataRecord["password"]."' WHERE webdav_user_id = ".$this->id;
161161
$app->db->query($sql);
162+
162163
}
163164

164165
function onBeforeUpdate() {
@@ -172,16 +173,7 @@ function onBeforeUpdate() {
172173
$this->dataRecord["username"] = $data['username'];
173174
$this->dataRecord["dir"] = $data['dir'];
174175
$this->dataRecord['username_prefix'] = $data['username_prefix'];
175-
$passwordOld = $data['password'];
176-
177-
/*
178-
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule
179-
* needs (only if the pwd is changed)
180-
*/
181-
if ((isset($this->dataRecord["password"])) && ($this->dataRecord["password"] != '') && ($this->dataRecord["password"] != $passwordOld)) {
182-
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
183-
$this->dataRecord["password"] = $hash;
184-
}
176+
$this->dataRecord['passwordOld'] = $data['password'];
185177

186178
parent::onBeforeUpdate();
187179
}
@@ -200,6 +192,17 @@ function onAfterUpdate() {
200192
$sql = "UPDATE webdav_user SET server_id = $server_id, sys_groupid = '$sys_groupid' WHERE webdav_user_id = ".$this->id;
201193
$app->db->query($sql);
202194
}
195+
196+
/*
197+
* We shall not save the pwd in plaintext, so we store it as the hash, the apache-moule
198+
* needs (only if the pwd is changed)
199+
*/
200+
if ((isset($this->dataRecord["password"])) && ($this->dataRecord["password"] != '') && ($this->dataRecord["password"] != $this->dataRecord['passwordOld'])) {
201+
$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
202+
$this->dataRecord["password"] = $hash;
203+
$app->db->query("UPDATE webdav_user SET password = '".$this->dataRecord["password"]."' WHERE webdav_user_id = ".$this->id);
204+
}
205+
203206
}
204207

205208
}

0 commit comments

Comments
 (0)