Permalink
Browse files

Fix to pydio/internal-tracker#108 : webdav upload for remote share ne…

…ver had write permissions
  • Loading branch information...
1 parent 9eaf681 commit 194334501a56a1d99f9a32abdc4ad9e707bf9239 @ghecquet ghecquet committed Sep 23, 2016
@@ -131,7 +131,6 @@ public function authenticate(Sabre\DAV\Server $server, $realm)
//AJXP_Logger::debug("Using Cached Password");
}
-
if (!$cachedPasswordValid && (!$this->validateUserPass($userpass[0],$userpass[1]))) {
Logger::warning(__CLASS__, "Login failed", array("user" => $userpass[0], "error" => "Invalid WebDAV user or password"));
$auth->requireLogin();
@@ -484,10 +484,10 @@ public function uploadAction(ServerRequestInterface &$request, ResponseInterface
}
// PARTIAL UPLOAD CASE - PREPPEND .dlpart extension
- if(isSet($httpVars["partial_upload"]) && $httpVars["partial_upload"] == 'true' && isSet($httpVars["partial_target_bytesize"])){
+ if(isSet($httpVars["partial_upload"]) && $httpVars["partial_upload"] == 'true' && isSet($httpVars["partial_target_bytesize"])) {
$partialUpload = true;
$partialTargetSize = intval($httpVars["partial_target_bytesize"]);
- if(!isSet($httpVars["appendto_urlencoded_part"])){
+ if(!isSet($httpVars["appendto_urlencoded_part"])) {
$userfile_name .= ".dlpart";
$targetUrl = $destination."/".$userfile_name;
}
@@ -70,10 +70,6 @@ public static function register($protocol) {
public function stream_open($path, $mode, $options, &$opened_path) {
$this->stream = self::createStream($path, $mode);
- if ($this->stream->isWritable() && !$this->stream->isReadable()) {
- $a = 1;
- }
-
return true;
}
@@ -341,7 +337,7 @@ public static function getResolvedOptionsForNode($node)
*/
public function stream_flush()
{
- // TODO: Implement stream_flush() method.
+ //$this->stream->flush();
}
/**
@@ -56,7 +56,6 @@ public function getContents() {
}
public function close() {
- //$this->bufferStream->close();
if ($this->size > 0) {
$this->stream->write($this->bufferStream);
}
@@ -68,17 +68,17 @@ public function __construct(ContextInterface $context){
*
* @param string $username
* @param string $password
- * @return bool
+ * @return mixed AJXP_User|bool
*/
protected function validateUserPass($username, $password)
{
try{
if(isSet($this->shareData["PRESET_LOGIN"])){
- AuthService::logUser($this->shareData["PRESET_LOGIN"], $password, false, false);
+ $user = AuthService::logUser($this->shareData["PRESET_LOGIN"], $password, false, false);
}else{
- AuthService::logUser($this->shareData["PRELOG_USER"], "", true);
+ $user = AuthService::logUser($this->shareData["PRELOG_USER"], "", true);
}
- return true;
+ return $user;
}catch (LoginException $l){
return false;
}
@@ -119,7 +119,9 @@ public function authenticate(DAV\Server $server, $realm) {
$auth->requireLogin();
throw new DAV\Exception\NotAuthenticated('Username or password does not match');
}
- if (!$this->validateUserPass($userpass[0],$userpass[1])) {
+
+ $user = $this->validateUserPass($userpass[0],$userpass[1]);
+ if (!$user) {
$auth->requireLogin();
throw new DAV\Exception\NotAuthenticated('Username or password does not match');
}
@@ -136,7 +138,7 @@ public function authenticate(DAV\Server $server, $realm) {
}
$this->currentUser = $userpass[0];
- $this->context->setUserId($this->currentUser);
+ $this->context->setUserObject($user);
Logger::updateContext($this->context);
TextEncoder::updateContext($this->context);

0 comments on commit 1943345

Please sign in to comment.