]> git.mxchange.org Git - friendica-addons.git/blobdiff - dav/friendica/dav_friendica_auth.inc.php
Update IT strings for securemail and viewsrc
[friendica-addons.git] / dav / friendica / dav_friendica_auth.inc.php
index acc33fa1e8fed132eb993acbbd42e73a5a60df44..88b8cf01a44405302a21c1a8636ffb49d4f0d226 100644 (file)
@@ -1,41 +1,41 @@
 <?php
 
-class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
-
-    public function __construct() {
-    }
-
+use Friendica\Model\User;
 
+class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic
+{
        /**
         * @var Sabre_DAV_Auth_Backend_Std|null
         */
-       private static $intstance = null;
+       private static $instance = null;
 
        /**
         * @static
         * @return Sabre_DAV_Auth_Backend_Std
         */
-       public static function &getInstance() {
-               if (is_null(self::$intstance)) {
-                       self::$intstance = new Sabre_DAV_Auth_Backend_Std();
+       public static function getInstance()
+       {
+               if (is_null(self::$instance)) {
+                       self::$instance = new Sabre_DAV_Auth_Backend_Std();
                }
-               return self::$intstance;
+               return self::$instance;
        }
 
-
        /**
         * @return array
         */
-       public function getUsers() {
-        return array($this->currentUser);
-    }
+       public function getUsers()
+       {
+               return [$this->currentUser];
+       }
 
        /**
         * @return null|string
         */
-       public function getCurrentUser() {
-        return $this->currentUser;
-    }
+       public function getCurrentUser()
+       {
+               return $this->currentUser;
+       }
 
        /**
         * Authenticates the user based on the current request.
@@ -48,8 +48,8 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
         * @throws Sabre_DAV_Exception_NotAuthenticated
         * @return bool
         */
-       public function authenticate(Sabre_DAV_Server $server, $realm) {
-
+       public function authenticate(Sabre_DAV_Server $server, $realm)
+       {
                $a = get_app();
                if (isset($a->user["uid"])) {
                        $this->currentUser = strtolower($a->user["nickname"]);
@@ -67,7 +67,7 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
                }
 
                // Authenticates the user
-               if (!$this->validateUserPass($userpass[0],$userpass[1])) {
+               if (!$this->validateUserPass($userpass[0], $userpass[1])) {
                        $auth->requireLogin();
                        throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match');
                }
@@ -75,19 +75,13 @@ class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
                return true;
        }
 
-
        /**
         * @param string $username
         * @param string $password
         * @return bool
         */
-       protected function validateUserPass($username, $password) {
-               $encrypted = hash('whirlpool',trim($password));
-               $r = q("SELECT COUNT(*) anz FROM `user` WHERE `nickname` = '%s' AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
-                       dbesc(trim($username)),
-                       dbesc($encrypted)
-               );
-               return ($r[0]["anz"] == 1);
-    }
-    
+       protected function validateUserPass($username, $password)
+       {
+               return User::authenticate($username, $password);
+       }
 }