mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
Heavily refactored, including multiple calendars per user and recurring events. Not in an installable state yet, though
This commit is contained in:
parent
4a5e30ec84
commit
fefee23e90
78 changed files with 8026 additions and 1205 deletions
|
@ -1,16 +1,39 @@
|
|||
<?php
|
||||
|
||||
class Sabre_DAV_Auth_Backend_Friendica extends Sabre_DAV_Auth_Backend_AbstractBasic {
|
||||
class Sabre_DAV_Auth_Backend_Std extends Sabre_DAV_Auth_Backend_AbstractBasic {
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
|
||||
public function getUsers() {
|
||||
/**
|
||||
* @var Sabre_DAV_Auth_Backend_Std|null
|
||||
*/
|
||||
private static $intstance = 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();
|
||||
}
|
||||
return self::$intstance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getUsers() {
|
||||
return array($this->currentUser);
|
||||
}
|
||||
|
||||
public function getCurrentUser() {
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
return $this->currentUser;
|
||||
}
|
||||
|
||||
|
@ -27,6 +50,12 @@ class Sabre_DAV_Auth_Backend_Friendica extends Sabre_DAV_Auth_Backend_AbstractBa
|
|||
*/
|
||||
public function authenticate(Sabre_DAV_Server $server, $realm) {
|
||||
|
||||
$a = get_app();
|
||||
if (isset($a->user["uid"])) {
|
||||
$this->currentUser = strtolower($a->user["nickname"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
$auth = new Sabre_HTTP_BasicAuth();
|
||||
$auth->setHTTPRequest($server->httpRequest);
|
||||
$auth->setHTTPResponse($server->httpResponse);
|
||||
|
@ -47,12 +76,18 @@ class Sabre_DAV_Auth_Backend_Friendica extends Sabre_DAV_Auth_Backend_AbstractBa
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateUserPass($username, $password) {
|
||||
|
||||
$user = array(
|
||||
'uri' => "/" . 'principals/users/' . strtolower($username),
|
||||
$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 $user;
|
||||
return ($r[0]["anz"] == 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue