Commit cd56a89b authored by Clément OUDOT's avatar Clément OUDOT
Browse files

Create a stop method to know if the Multi process should stop (#914)

parent 333403df
...@@ -94,4 +94,18 @@ sub getDisplayType { ...@@ -94,4 +94,18 @@ sub getDisplayType {
return "standardform"; return "standardform";
} }
## @method boolean stop
# Define which error codes will stop Multi process
# @param res error code
# @return result 1 if stop is needed
sub stop {
my ( $self, $res ) = @_;
return 1
if ( $res == PE_PP_PASSWORD_EXPIRED
or $res == PE_PP_ACCOUNT_LOCKED
or $res == PE_PP_CHANGE_AFTER_RESET );
return 0;
}
1; 1;
...@@ -83,12 +83,7 @@ sub try { ...@@ -83,12 +83,7 @@ sub try {
# Run subroutine # Run subroutine
$res = $self->{p}->$s(); $res = $self->{p}->$s();
# Stop if no error, or if confirmation needed, or if form not filled return $res if $self->stop( $type, $res );
return $res
if ( $res <= 0
or $res == PE_CONFIRM
or $res == PE_FIRSTACCESS
or $res == PE_FORMEMPTY );
} }
unless ( $self->next($type) ) { unless ( $self->next($type) ) {
return ( $ci ? $res : $self->{res} ); return ( $ci ? $res : $self->{res} );
...@@ -103,6 +98,34 @@ sub try { ...@@ -103,6 +98,34 @@ sub try {
return $res; return $res;
} }
## @method protected boolean stop(int type, int res)
# Call specific backend to know if multi process should stop
# @param type 0 for authentication, 1 for userDB
# @param res return code of last executed sub
# return true if process should stop
sub stop {
my ( $self, $type, $res ) = @_;
# Stop if no error, or if confirmation needed, or if form not filled
return 1
if ( $res <= 0
or $res == PE_CONFIRM
or $res == PE_FIRSTACCESS
or $res == PE_FORMEMPTY );
# Check specific backend stop method
my $stopSub = $self->{stack}->[$type]->[0]->{m} . "::stop";
my $ret = 0;
eval { $ret = $self->{p}->$stopSub($res); };
if ($@) {
$self->{p}->lmLog( $@, 'debug' );
return 0;
}
return $ret;
}
## @method protected boolean next(int type) ## @method protected boolean next(int type)
# Set the next authentication or userDB module as current. If both # Set the next authentication or userDB module as current. If both
# authentication and userDB module have the same name, both are changed if # authentication and userDB module have the same name, both are changed if
......
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