diff --git a/e2e-tests/lemonldap-ng.ini b/e2e-tests/lemonldap-ng.ini index a095950f5..7b09ee245 100644 --- a/e2e-tests/lemonldap-ng.ini +++ b/e2e-tests/lemonldap-ng.ini @@ -21,7 +21,7 @@ notification = 0 checkXSS = 0 portalSkin = bootstrap staticPrefix = / -templateDir = __pwd__/lemonldap-ng-portal/example/skin +templateDir = __pwd__/lemonldap-ng-portal/example/skins [handler] diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm index 7f7af7532..d0486726a 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm @@ -85,15 +85,15 @@ sub display { #utf8::decode($auth_user); %templateParams = ( - AUTH_USER => $auth_user, - NEWWINDOW => $self->conf->{portalOpenLinkInNewWindow}, - AUTH_ERROR => $req->errorString( $req->{menuError} ), - AUTH_ERROR_TYPE => $req->error_type( $req->{menuError} ), - DISPLAY_TAB => $self->conf->{menuDisplayTab}, - LOGOUT_URL => $self->conf->{portal} . "?logout=1", + AUTH_USER => $auth_user, + NEWWINDOW => $self->conf->{portalOpenLinkInNewWindow}, + AUTH_ERROR => $req->errorString( $req->{menuError} ), + AUTH_ERROR_TYPE => $req->error_type( $req->{menuError} ), + DISPLAY_TAB => $self->conf->{menuDisplayTab}, + LOGOUT_URL => $self->conf->{portal} . "?logout=1", DISPLAY_MODULES => $self->conf->{menuDisplayModules} || [], - APPSLIST_ORDER => $req->{sessionInfo}->{'appsListOrder'}, - PING => $self->conf->{portalPingInterval}, + APPSLIST_ORDER => $req->{sessionInfo}->{'appsListOrder'}, + PING => $self->conf->{portalPingInterval}, ); } @@ -109,7 +109,7 @@ sub display { AUTH_ERROR_TYPE => $req->error_type, NOTIFICATION => $notif, HIDDEN_INPUTS => $self->buildHiddenForm(), - AUTH_URL => $self->get_url, + AUTH_URL => $req->{datas}->{_url}, CHOICE_PARAM => $self->conf->{authChoiceParam}, CHOICE_VALUE => $req->{_authChoice}, ); @@ -122,7 +122,7 @@ sub display { %templateParams = ( AUTH_ERROR => $req->error, AUTH_ERROR_TYPE => $req->error_type, - AUTH_URL => $self->get_url, + AUTH_URL => $req->{datas}->{_url}, MSG => $req->info, HIDDEN_INPUTS => $self->buildHiddenForm(), ACTIVE_TIMER => $self->conf->{activeTimer}, @@ -181,7 +181,7 @@ sub display { %templateParams = ( AUTH_ERROR => $req->error, AUTH_ERROR_TYPE => $req->error_type, - AUTH_URL => $self->get_url, + AUTH_URL => $req->{datas}->{_url}, LOGIN => $login, CHECK_LOGINS => $self->conf->{portalCheckLogins}, ASK_LOGINS => $self->conf->{checkLogins}, diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm index 085715345..14b7de859 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm @@ -5,6 +5,7 @@ package Lemonldap::NG::Portal::Main::Request; use strict; use Mouse; +use Lemonldap::NG::Portal::Main::Constants; extends 'Lemonldap::NG::Common::PSGI::Request'; @@ -49,6 +50,41 @@ sub wantJSON { # Error type sub error_type { + my $req = shift; + my $code = shift || $req->error; + + # Positive errors + return "positive" + if ( + scalar( + grep { /^$code$/ } ( + PE_REDIRECT, PE_DONE, + PE_OK, PE_PASSWORD_OK, + PE_MAILOK, PE_LOGOUT_OK, + PE_MAILFIRSTACCESS, PE_PASSWORDFIRSTACCESS, + PE_MAILCONFIRMOK, PE_REGISTERFIRSTACCESS, + ) + ) + ); + + # Warning errors + return "warning" + if ( + scalar( + grep { /^$code$/ } ( + PE_INFO, PE_SESSIONEXPIRED, + PE_FORMEMPTY, PE_FIRSTACCESS, + PE_PP_GRACE, PE_PP_EXP_WARNING, + PE_NOTIFICATION, PE_BADURL, + PE_CONFIRM, PE_MAILFORMEMPTY, + PE_MAILCONFIRMATION_ALREADY_SENT, PE_PASSWORDFORMEMPTY, + PE_CAPTCHAEMPTY, PE_REGISTERFORMEMPTY, + ) + ) + ); + + # Negative errors (default) + return "negative"; #TODO } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm index 3e03a58cf..b16354dc2 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Run.pm @@ -92,7 +92,7 @@ sub authenticatedRequest { sub do { my ( $self, $req, $steps ) = @_; $req->steps($steps); - my $err = $self->process($req); + my $err = $req->error( $self->process($req) ); # TODO: updateStatus if ( !$self->conf->{noAjaxHook} and $req->wantJSON ) {