Merge pull request #15076 from owncloud/fix-smb-oc-admin

Support constructing an SMB_OC without saved session credentials
This commit is contained in:
Robin McCorkell 2015-03-30 15:38:22 +01:00
commit 308a43a10e
1 changed files with 11 additions and 4 deletions

View File

@ -38,13 +38,20 @@ class SMB_OC extends SMB {
* @throws \Exception * @throws \Exception
*/ */
public function __construct($params) { public function __construct($params) {
if (isset($params['host']) && \OC::$server->getSession()->exists('smb-credentials')) { if (isset($params['host'])) {
$host = $params['host']; $host = $params['host'];
$this->username_as_share = ($params['username_as_share'] === 'true'); $this->username_as_share = ($params['username_as_share'] === 'true');
// dummy credentials, unused, to satisfy constructor
$user = 'foo';
$password = 'bar';
if (\OC::$server->getSession()->exists('smb-credentials')) {
$params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true); $params_auth = json_decode(\OC::$server->getCrypto()->decrypt(\OC::$server->getSession()->get('smb-credentials')), true);
$user = \OC::$server->getSession()->get('loginname'); $user = \OC::$server->getSession()->get('loginname');
$password = $params_auth['password']; $password = $params_auth['password'];
} else {
// assume we are testing from the admin section
}
$root = isset($params['root']) ? $params['root'] : '/'; $root = isset($params['root']) ? $params['root'] : '/';
$share = ''; $share = '';