Unverified Commit d81f4ce3 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Fix ldap disabled (#1670)

* fix(frontend): remove USB hardware

* fix(frontend): do not try LDAP if not enabled
parent 7937ed15
......@@ -2427,7 +2427,8 @@ sub display_ip($self=undef, $new_ip=undef) {
$CONFIG->{display_ip} = $new_ip;
}
}
my $ip = $CONFIG->{display_ip};
my $ip;
$ip = $CONFIG->{display_ip} if exists $CONFIG->{display_ip};
return $ip if $ip;
}
......@@ -2468,6 +2469,7 @@ sub _init_config {
delete $default_vms{Void};
$CONFIG->{vm} = [keys %default_vms];
}
# lock_hash(%$CONFIG);
# $CONNECTOR = ( $connector or _connect_dbh());
_init_config_vm();
......
......@@ -22,7 +22,7 @@ Initializes the submodules
sub init {
my ($config, $db_con) = @_;
if ($config->{ldap} && (!defined $LDAP_OK || $LDAP_OK) ) {
if (exists $config->{ldap} && $config->{ldap} && (!defined $LDAP_OK || $LDAP_OK) ) {
eval {
$LDAP_OK = 0;
require Ravada::Auth::LDAP;
......@@ -34,7 +34,7 @@ sub init {
$LDAP_OK = 0;
}
if ($config->{sso} && (!defined $SSO_OK || $SSO_OK) ) {
if (exists $config->{sso} && $config->{sso} && (!defined $SSO_OK || $SSO_OK) ) {
eval {
$SSO_OK = 0;
require Ravada::Auth::SSO;
......
......@@ -911,7 +911,7 @@ sub _init_ldap_admin {
return $LDAP_ADMIN if $LDAP_ADMIN;
my ($dn, $pass);
if ($$CONFIG->{ldap} ) {
if (exists $$CONFIG->{ldap} && $$CONFIG->{ldap} ) {
($dn, $pass) = ( $$CONFIG->{ldap}->{admin_user}->{dn}
, $$CONFIG->{ldap}->{admin_user}->{password});
} else {
......
......@@ -3496,13 +3496,16 @@ sub maintenance($c) {
}
sub _list_ldap_groups($c, $name='*') {
return $c->render(json => []) if !$RAVADA->feature('ldap');
$name = '*'.$name.'*' if $name !~ /\*/;
my @groups;
@groups = Ravada::Auth::LDAP::search_group( name => $name ) if $RAVADA->feature('ldap');
my @groups = Ravada::Auth::LDAP::search_group( name => $name );
return $c->render(json => [ sort { $a cmp $b } map { $_->get_value('cn') } @groups ] );
};
sub _list_ldap_users($c, $filter='*' ) {
return $c->render(json => []) if !$RAVADA->feature('ldap');
$filter = '*' if $filter eq 'undefined';
$filter = '*'.$filter if length($filter) && $filter !~ /^\*/;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment