From 16129daaeb9d891965f448cfe767073866293c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Fri, 28 Oct 2011 15:52:19 +0000 Subject: [PATCH] Specific mail user not found error for mail reset (#377) --- .../lib/Lemonldap/NG/Handler/Status.pm | 1 + modules/lemonldap-ng-portal/example/mail.pl | 2 +- .../lib/Lemonldap/NG/Portal/MailReset.pm | 19 +++++++++++++++++-- .../lib/Lemonldap/NG/Portal/Simple.pm | 6 +++++- .../lib/Lemonldap/NG/Portal/_i18n.pm | 4 ++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Status.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Status.pm index 3cd78828a..8359e7161 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Status.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Status.pm @@ -87,6 +87,7 @@ sub portalTab { 67 => 'PORTAL_PASSWORDFORMEMPTY', 68 => 'PORTAL_CAS_SERVICE_NOT_ALLOWED', 69 => 'PORTAL_MAILFIRSTACCESS', + 70 => 'PORTAL_MAILNOTFOUND', }; } diff --git a/modules/lemonldap-ng-portal/example/mail.pl b/modules/lemonldap-ng-portal/example/mail.pl index 32e0f9cfd..ec8871300 100755 --- a/modules/lemonldap-ng-portal/example/mail.pl +++ b/modules/lemonldap-ng-portal/example/mail.pl @@ -44,7 +44,7 @@ if ( ( $portal->{error} == PE_MAILFORMEMPTY or $portal->{error} == PE_MAILFIRSTACCESS - or $portal->{error} == PE_BADCREDENTIALS + or $portal->{error} == PE_MAILNOTFOUND ) and !$portal->{mail_token} ) diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/MailReset.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/MailReset.pm index 4d5eb8375..f8a2b1515 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/MailReset.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/MailReset.pm @@ -27,6 +27,7 @@ use POSIX; # - itself: # - smtpInit # - extractMailInfo +# - getMailUser # - storeMailSession # - sendConfirmationMail # - changePassword @@ -37,7 +38,6 @@ use POSIX; # - setGroups # - userDB module: # - userDBInit -# - getUser # - setSessionInfo # - passwordDB module: # - passwordDBInit @@ -50,7 +50,7 @@ sub process { $self->{error} = $self->_subProcess( qw(smtpInit userDBInit passwordDBInit extractMailInfo - getUser setSessionInfo setMacros setLocalGroups setGroups setPersistentSessionInfo + getMailUser setSessionInfo setMacros setLocalGroups setGroups setPersistentSessionInfo storeMailSession sendConfirmationMail changePassword sendPasswordMail) ); @@ -124,6 +124,21 @@ sub extractMailInfo { PE_OK; } +## @method int getMailUser +# Search for user using UserDB module +# @return Lemonldap::NG::Portal constant +sub getMailUser { + my ($self) = splice @_; + + my $error = $self->getUser(); + + if ( $error == PE_USERNOTFOUND or $error == PE_BADCREDENTIALS ) { + return PE_MAILNOTFOUND; + } + + return $error; +} + ## @method int storeMailSession # Create mail session and store token # @return Lemonldap::NG::Portal constant diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index 7f95947c5..85e74bd7d 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -139,6 +139,7 @@ use constant { PE_PASSWORDFORMEMPTY => 67, PE_CAS_SERVICE_NOT_ALLOWED => 68, PE_MAILFIRSTACCESS => 69, + PE_MAILNOTFOUND => 70, # Portal messages PM_USER => 0, @@ -183,6 +184,7 @@ our @EXPORT = qw( PE_IMG_NOK PE_IMG_OK PE_INFO PE_REDIRECT PE_DONE PE_OK PE_SAML_LOAD_SP_ERROR PE_SAML_ATTR_ERROR PE_OPENID_EMPTY PE_OPENID_BADID PE_MISSINGREQATTR PE_BADPARTNER PE_MAILCONFIRMATION_ALREADY_SENT PE_PASSWORDFORMEMPTY PE_CAS_SERVICE_NOT_ALLOWED PE_MAILFIRSTACCESS + PE_MAILNOTFOUND PM_USER PM_DATE PM_IP PM_SESSIONS_DELETED PM_OTHER_SESSIONS PM_REMOVE_OTHER_SESSIONS PM_PP_GRACE PM_PP_EXP_WARNING PM_SAML_IDPSELECT PM_SAML_IDPCHOOSEN PM_REMEMBERCHOICE PM_SAML_SPLOGOUT @@ -794,8 +796,10 @@ sub error_type { if ( scalar( grep { /^$code$/ } ( - PE_REDIRECT, PE_DONE, PE_OK, PE_PASSWORD_OK, + PE_REDIRECT, PE_DONE, + PE_OK, PE_PASSWORD_OK, PE_MAILOK, PE_LOGOUT_OK, + PE_MAILFIRSTACCESS, ) ) ); diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm index 18733fe08..978f8d1d9 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_i18n.pm @@ -129,6 +129,7 @@ __END__ # * PE_PASSWORDFORMEMPTY 67 # * PE_CAS_SERVICE_NOT_ALLOWED 68 # * PE_MAILFIRSTACCESS 69 +# * PE_MAILNOTFOUND 70 # Not used in errors: # * PE_DONE -1 @@ -210,6 +211,7 @@ sub error_fr { 'Mot de passe non renseigné', 'Accès non autorisé au service CAS', 'Merci de saisir votre adresse mail', + 'Pas d\'utilisateur correspondant', ]; } @@ -288,6 +290,7 @@ sub error_en { 'Password field must be filled', 'Access non granted on CAS service', 'Please provide your mail address', + 'No matching user', ]; } @@ -367,6 +370,7 @@ sub error_ro { 'Password field must be filled', 'Access non granted on CAS service', 'Vă rugăm să introduceţi adresa dvs. de e-mail', + 'No matching user', ]; }