Improve code

This commit is contained in:
Christophe Maudoux 2022-06-03 19:17:01 +02:00
parent 3f783f4805
commit 651beaf130
6 changed files with 19 additions and 27 deletions

View File

@ -4,10 +4,10 @@ use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);
our $VERSION = '2.0.8';
our $VERSION = '2.0.15';
sub init {
1;
return 1;
}
## @method int modifCertificate

View File

@ -7,7 +7,7 @@ use Lemonldap::NG::Common::FormEncode;
use Lemonldap::NG::Portal::Main::Constants
qw(PE_OK PE_BADURL PE_GET_SERVICE_NOT_ALLOWED URIRE);
our $VERSION = '2.0.12';
our $VERSION = '2.0.15';
extends 'Lemonldap::NG::Portal::Main::Issuer';
@ -29,7 +29,7 @@ sub init {
return 0;
}
$self->{rule} = $rule;
return 0 unless ( $self->SUPER::init() );
return 0 unless $self->SUPER::init();
return 1;
}
@ -71,7 +71,7 @@ sub run {
# Nothing to do here for now
sub logout {
PE_OK;
return PE_OK;
}
# INTERNAL METHODS

View File

@ -5,18 +5,18 @@ use JSON;
use Mouse;
use Lemonldap::NG::Common::Regexp;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_BADPARTNER
PE_CONFIRM
PE_ERROR
PE_OK
PE_ERROR
PE_CONFIRM
PE_REDIRECT
PE_BADPARTNER
PE_OPENID_BADID
PE_OPENID_EMPTY
PE_REDIRECT
PE_SENDRESPONSE
PE_OID_SERVICE_NOT_ALLOWED
);
our $VERSION = '2.0.3';
our $VERSION = '2.0.15';
extends 'Lemonldap::NG::Portal::Main::Issuer';
@ -131,7 +131,7 @@ sub run {
}
sub logout {
PE_OK;
return PE_OK;
}
# INTERNAL METHODS

View File

@ -17,7 +17,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
extends 'Lemonldap::NG::Portal::Main::Plugin';
our $VERSION = '2.0.14';
our $VERSION = '2.0.15';
# INITIALIZATION
@ -75,8 +75,6 @@ sub _modifyPassword {
# Check if portal require old password
if ( $oldPwdRule->( $req, $req->userData ) or $requireOldPwd ) {
# TODO: verify oldpassword
unless ( $req->data->{oldpassword} = $req->param('oldpassword') ) {
$self->logger->warn("Portal require old password");
return PE_PP_MUST_SUPPLY_OLD_PASSWORD;
@ -84,7 +82,7 @@ sub _modifyPassword {
# Verify old password
return PE_BADOLDPASSWORD
unless ( $self->confirm( $req, $req->data->{oldpassword} ) );
unless $self->confirm( $req, $req->data->{oldpassword} );
}
my $cpq =
@ -242,12 +240,7 @@ sub setNewPassword {
$hook_result =
$self->p->processHook( $req, 'passwordAfterChange', $req->user,
$pwd );
if ( $hook_result != PE_OK ) {
return $hook_result;
}
else {
return PE_PASSWORD_OK;
}
return ( $hook_result != PE_OK ) ? $hook_result : PE_PASSWORD_OK;
}
else {
return $mod_result;

View File

@ -16,8 +16,9 @@ extends qw(
our $VERSION = '2.0.10';
sub init {
$_[0]->Lemonldap::NG::Portal::Password::Base::init
and $_[0]->Lemonldap::NG::Portal::Lib::DBI::init;
my ($self) = @_;
$self->Lemonldap::NG::Portal::Password::Base::init
and $self->Lemonldap::NG::Portal::Lib::DBI::init;
}
sub confirm {

View File

@ -14,7 +14,7 @@ extends qw(
Lemonldap::NG::Portal::Password::Base
);
our $VERSION = '2.0.10';
our $VERSION = '2.0.15';
sub init {
my ($self) = @_;
@ -63,10 +63,8 @@ sub modifyPassword {
my $code =
$self->ldap->userModifyPassword( $dn, $pwd, $req->data->{oldpassword},
0, $requireOldPassword );
return $code unless ( $code == PE_PASSWORD_OK );
unless ( $code == PE_PASSWORD_OK ) {
return $code;
}
# If password policy and force reset, set reset flag
if ( $self->conf->{ldapPpolicyControl}