@@ -9,12 +9,11 @@
|
||||
namespace OCA\UserExternal;
|
||||
|
||||
class WebDavAuth extends Base {
|
||||
|
||||
private $webDavAuthUrl;
|
||||
|
||||
public function __construct($webDavAuthUrl) {
|
||||
parent::__construct($webDavAuthUrl);
|
||||
$this->webDavAuthUrl =$webDavAuthUrl;
|
||||
$this->webDavAuthUrl = $webDavAuthUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,21 +26,20 @@ class WebDavAuth extends Base {
|
||||
*/
|
||||
public function checkPassword($uid, $password) {
|
||||
$arr = explode('://', $this->webDavAuthUrl, 2);
|
||||
if( ! isset($arr) OR count($arr) !== 2) {
|
||||
if (! isset($arr) or count($arr) !== 2) {
|
||||
\OC::$server->getLogger()->error('ERROR: Invalid WebdavUrl: "'.$this->webDavAuthUrl.'" ', ['app' => 'user_external']);
|
||||
return false;
|
||||
}
|
||||
list($protocol, $path) = $arr;
|
||||
$url= $protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$path;
|
||||
$url = $protocol.'://'.urlencode($uid).':'.urlencode($password).'@'.$path;
|
||||
$headers = get_headers($url);
|
||||
if($headers === false) {
|
||||
if ($headers === false) {
|
||||
\OC::$server->getLogger()->error('ERROR: Not possible to connect to WebDAV Url: "'.$protocol.'://'.$path.'" ', ['app' => 'user_external']);
|
||||
return false;
|
||||
|
||||
}
|
||||
$returnCode= substr($headers[0], 9, 3);
|
||||
$returnCode = substr($headers[0], 9, 3);
|
||||
|
||||
if(substr($returnCode, 0, 1) === '2') {
|
||||
if (substr($returnCode, 0, 1) === '2') {
|
||||
$this->storeUser($uid);
|
||||
return $uid;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user