diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDemo.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDemo.pm index 10233b106..9f09d92eb 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDemo.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDemo.pm @@ -8,7 +8,7 @@ package Lemonldap::NG::Portal::UserDBDemo; use strict; use Lemonldap::NG::Portal::Simple; -our $VERSION = '1.2.0'; +our $VERSION = '1.3.0'; ## @apmethod int userDBInit() # Check AuthDemo use @@ -17,6 +17,10 @@ sub userDBInit { my $self = shift; if ( $self->get_module('auth') eq 'Demo' ) { + + # Call authInit if demo accounts not found + $self->authInit() unless defined $self->{_demoAccounts}; + return PE_OK; } else { @@ -33,10 +37,23 @@ sub userDBInit { sub getUser { my $self = shift; - return PE_USERNOTFOUND - unless ( defined $self->{_demoAccounts}->{ $self->{user} } ); + # Search by login + if ( $self->{user} ) { + return PE_OK + if ( defined $self->{_demoAccounts}->{ $self->{user} } ); + } - PE_OK; + # Search by mail + if ( $self->{mail} ) { + foreach my $user ( keys %{ $self->{_demoAccounts} } ) { + if ( $self->{_demoAccounts}->{$user}->{mail} eq $self->{mail} ) { + $self->{user} = $user; + return PE_OK; + } + } + } + + PE_USERNOTFOUND; } ## @apmethod int setSessionInfo()