From 85ed9404f9b6fee47473cfcf25b47be68faaeee9 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 5 Jan 2014 14:12:53 -0800 Subject: the web browser interface for DAV has now got zot --- mod/cloud.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'mod/cloud.php') diff --git a/mod/cloud.php b/mod/cloud.php index 106379785..024aa9ef3 100644 --- a/mod/cloud.php +++ b/mod/cloud.php @@ -79,6 +79,7 @@ class RedBasicAuth extends Sabre\DAV\Auth\Backend\AbstractBasic { if(($record['account_flags'] == ACCOUNT_OK) || ($record['account_flags'] == ACCOUNT_UNVERIFIED) && (hash('whirlpool',$record['account_salt'] . $password) === $record['account_password'])) { logger('(DAV) RedBasicAuth: password verified for ' . $username); + $this->currentUser = $r[0]['channel_address']; $this->channel_name = $r[0]['channel_address']; $this->channel_id = $r[0]['channel_id']; $this->channel_hash = $this->observer = $r[0]['channel_hash']; @@ -90,6 +91,12 @@ class RedBasicAuth extends Sabre\DAV\Auth\Backend\AbstractBasic { logger('(DAV) RedBasicAuth: password failed for ' . $username); return false; } + + function setCurrentUser($name) { + $this->currentUser = $name; + } + + } @@ -102,6 +109,20 @@ function cloud_init(&$a) { $auth = new RedBasicAuth(); + $ob_hash = get_observer_hash(); + + if($ob_hash) { + if(local_user()) { + $channel = $a->get_channel(); + $auth->setCurrentUser($channel['channel_address']); + $auth->channel_name = $channel['channel_address']; + $auth->channel_id = $channel['channel_id']; + $auth->channel_hash = $channel['channel_hash']; + } + $auth->observer = $ob_hash; + } + + $rootDirectory = new RedDirectory('/',$auth); $server = new DAV\Server($rootDirectory); $lockBackend = new DAV\Locks\Backend\File('store/data/locks'); @@ -110,7 +131,8 @@ function cloud_init(&$a) { $server->addPlugin($lockPlugin); - $auth->Authenticate($server,'Red Matrix'); + if(! $auth->observer) + $auth->Authenticate($server,'Red Matrix'); $browser = new DAV\Browser\Plugin(); $server->addPlugin($browser); -- cgit v1.2.3