1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

fix ldap auth

This commit is contained in:
Kay0u 2024-05-22 01:42:50 +02:00
parent de642dcf69
commit 5b77cd2f4d
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156
3 changed files with 18 additions and 12 deletions

View file

@ -1,13 +1,15 @@
<?php
use Dotclear\App;
use Dotclear\Core\Auth;
class ldapDcAuth extends Auth
{
# The user can't change his password
protected $allow_pass_change = false;
protected bool $allow_pass_change = false;
# LDAP parameter
private $server = "localhost";
private $port = "389";
private $base = "dc=yunohost,dc=org";
private string $server = "localhost";
private string $port = "389";
private string $base = "dc=yunohost,dc=org";
public function checkUser(string $user_id, ?string $pwd = NULL, ?string $user_key = NULL, bool $check_blog = true): bool
{
@ -56,9 +58,9 @@ class ldapDcAuth extends Auth
}
# If the user exist, then we just update his password.
if (dcCore::app()->userExists($user_id))
if (App::users()->userExists($user_id))
{
$this->sudo(array(dcCore::app(), 'updUser'), $user_id, $cur);
$this->sudo(array(App::users(), 'updUser'), $user_id, $cur);
}
# If not, we create him.
# In order for him to connect,
@ -69,7 +71,7 @@ class ldapDcAuth extends Auth
$cur->user_lang = 'fr'; # Can change this, PR are welcome
$cur->user_tz = 'Europe/Paris'; # Can change this, PR are welcome
$cur->user_default_blog = 'default'; # Can change this, PR are welcome
$this->sudo(array(dcCore::app(),'addUser'), $cur);
$this->sudo(array(App::users(),'addUser'), $cur);
# Possible roles:
# admin "administrator"
# contentadmin "manage all entries and comments"
@ -100,7 +102,7 @@ class ldapDcAuth extends Auth
$set_perms[$perm_id] = true;
}
}
$this->sudo(array(dcCore::app(), 'setUserBlogPermissions'), $user_id, 'default', $set_perms, true);
$this->sudo(array(App::users(), 'setUserBlogPermissions'), $user_id, 'default', $set_perms, true);
}
$this->con->commit();

View file

@ -95,8 +95,10 @@ ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_
cat << EOF >> $php_config
require dirname(__FILE__).'/class.auth.ldap.php';
define('DC_AUTH_CLASS','ldapDcAuth');
require_once dirname(__FILE__).'/class.auth.ldap.php';
define('DC_AUTH_LDAP','ldapDcAuth');
use Dotclear\Helper\Container\Factories;
Factories::addService("core", AuthInterface::class, DC_AUTH_LDAP);
EOF
ynh_store_file_checksum --file=$php_config

View file

@ -116,8 +116,10 @@ ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_
cat << EOF >> $php_config
require dirname(__FILE__).'/class.auth.ldap.php';
define('DC_AUTH_CLASS','ldapDcAuth');
require_once dirname(__FILE__).'/class.auth.ldap.php';
define('DC_AUTH_LDAP','ldapDcAuth');
use Dotclear\Helper\Container\Factories;
Factories::addService("core", AuthInterface::class, DC_AUTH_LDAP);
EOF
# Recalculate and store the checksum of the file for the next upgrade.