Dismiss cache if cfgDate has changed (#2508)
This commit is contained in:
parent
8ae9985e7c
commit
6be4cfe035
|
@ -122,7 +122,9 @@ sub saveConf {
|
|||
|
||||
# If configuration was modified, return an error
|
||||
if ( not $args{force} ) {
|
||||
return CONFIG_WAS_CHANGED if ( $conf->{cfgNum} != $last );
|
||||
return CONFIG_WAS_CHANGED
|
||||
if ( $conf->{cfgNum} ne $last
|
||||
|| $args{cfgDate} && $args{cfgDate} ne $args{currentCfgDate} );
|
||||
return DATABASE_LOCKED if ( $self->isLocked() or not $self->lock() );
|
||||
}
|
||||
$conf->{cfgNum} = $last + 1 unless ( $args{cfgNumFixed} );
|
||||
|
|
|
@ -123,7 +123,7 @@ sub newRSAKey {
|
|||
my $keys = {
|
||||
'private' => $rsa->get_private_key_string(),
|
||||
'public' => $rsa->get_public_key_x509_string(),
|
||||
'hash' => md5_base64($rsa->get_public_key_string()),
|
||||
'hash' => md5_base64( $rsa->get_public_key_string() ),
|
||||
};
|
||||
if ( $query->{password} ) {
|
||||
my $pem = Convert::PEM->new(
|
||||
|
@ -345,26 +345,25 @@ sub newConf {
|
|||
|
||||
# Body must be json
|
||||
my $new = $req->jsonBodyToObj;
|
||||
unless ( defined($new) ) {
|
||||
return $self->sendError( $req, undef, 400 );
|
||||
}
|
||||
return $self->sendError( $req, undef, 400 ) unless ( defined $new );
|
||||
|
||||
# Verify that cfgNum has been asked
|
||||
unless ( defined $req->params('cfgNum') ) {
|
||||
return $self->sendError( $req, "Missing configuration number", 400 );
|
||||
}
|
||||
# Verify that cfgNum has been sent
|
||||
return $self->sendError( $req, "Missing configuration number", 400 )
|
||||
unless ( defined $req->params('cfgNum') );
|
||||
|
||||
# # Verify that cfgDate has been sent
|
||||
# return $self->sendError( $req, "Missing configuration date", 400 )
|
||||
# unless ( defined $req->params('cfgDate') );
|
||||
|
||||
# Set current conf to cfgNum
|
||||
unless ( defined $self->getConfByNum( $req->params('cfgNum') ) ) {
|
||||
return $self->sendError(
|
||||
$req,
|
||||
"Configuration "
|
||||
. $req->params('cfgNum')
|
||||
. " not available "
|
||||
. $Lemonldap::NG::Common::Conf::msg,
|
||||
400
|
||||
);
|
||||
}
|
||||
return $self->sendError(
|
||||
$req,
|
||||
"Configuration "
|
||||
. $req->params('cfgNum')
|
||||
. " not available "
|
||||
. $Lemonldap::NG::Common::Conf::msg,
|
||||
400
|
||||
) unless ( defined $self->getConfByNum( $req->params('cfgNum') ) );
|
||||
|
||||
# Parse new conf
|
||||
require Lemonldap::NG::Manager::Conf::Parser;
|
||||
|
@ -372,13 +371,20 @@ sub newConf {
|
|||
{ tree => $new, refConf => $self->currentConf, req => $req } );
|
||||
|
||||
# If ref conf isn't last conf, consider conf changed
|
||||
my $cfgNum = $self->confAcc->lastCfg;
|
||||
unless ( defined $cfgNum ) {
|
||||
$req->error($Lemonldap::NG::Common::Conf::msg);
|
||||
}
|
||||
my $currentCfgNum = $self->confAcc->lastCfg;
|
||||
$req->error($Lemonldap::NG::Common::Conf::msg)
|
||||
unless ( defined $currentCfgNum );
|
||||
return $self->sendError( $req, undef, 400 ) if ( $req->error );
|
||||
|
||||
if ( $cfgNum ne $req->params('cfgNum') ) { $parser->confChanged(1); }
|
||||
my $currentConf =
|
||||
$self->confAcc->getConf(
|
||||
{ CfgNum => $currentCfgNum, raw => 1, noCache => 1 } );
|
||||
my $currentCfgDate = $currentConf->{cfgDate};
|
||||
$self->logger->debug(
|
||||
"Current CfgNum/cfgDate: $currentCfgNum/$currentCfgDate");
|
||||
$parser->confChanged(1)
|
||||
if ( $currentCfgNum ne $req->params('cfgNum')
|
||||
|| $req->params('cfgDate')
|
||||
&& $req->params('cfgDate') ne $currentCfgDate );
|
||||
|
||||
my $res = { result => $parser->check( $self->p ) };
|
||||
|
||||
|
@ -402,6 +408,10 @@ sub newConf {
|
|||
else {
|
||||
my %args;
|
||||
$args{force} = 1 if ( $req->params('force') );
|
||||
if ( $req->params('cfgDate') ) {
|
||||
$args{cfgDate} = $req->params('cfgDate');
|
||||
$args{currentCfgDate} = $currentCfgDate;
|
||||
}
|
||||
my $s = CONFIG_WAS_CHANGED;
|
||||
$s = $self->confAcc->saveConf( $parser->newConf, %args )
|
||||
unless ( @{ $parser->{needConfirmation} } && !$args{force} );
|
||||
|
|
|
@ -189,7 +189,7 @@ llapp.controller 'TreeCtrl', [
|
|||
id: "cfgLog"
|
||||
title: "cfgLog"
|
||||
data: if $scope.result then $scope.result else ''
|
||||
$http.post("#{window.confPrefix}?cfgNum=#{$scope.currentCfg.cfgNum}#{if $scope.forceSave then "&force=1" else ''}", $scope.data).then (response) ->
|
||||
$http.post("#{window.confPrefix}?cfgNum=#{$scope.currentCfg.cfgNum}&cfgDate=#{$scope.currentCfg.cfgDate}#{if $scope.forceSave then "&force=1" else ''}", $scope.data).then (response) ->
|
||||
$scope.data.pop()
|
||||
_checkSaveResponse response.data
|
||||
,(response) ->
|
||||
|
|
|
@ -225,7 +225,7 @@ This file contains:
|
|||
title: "cfgLog",
|
||||
data: $scope.result ? $scope.result : ''
|
||||
});
|
||||
return $http.post(window.confPrefix + "?cfgNum=" + $scope.currentCfg.cfgNum + ($scope.forceSave ? "&force=1" : ''), $scope.data).then(function(response) {
|
||||
return $http.post(window.confPrefix + "?cfgNum=" + $scope.currentCfg.cfgNum + "&cfgDate=" + $scope.currentCfg.cfgDate + ($scope.forceSave ? "&force=1" : ''), $scope.data).then(function(response) {
|
||||
$scope.data.pop();
|
||||
return _checkSaveResponse(response.data);
|
||||
}, function(response) {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@ use JSON;
|
|||
use strict;
|
||||
require 't/test-lib.pm';
|
||||
|
||||
my $tests = 18;
|
||||
my $tests = 17;
|
||||
|
||||
use_ok('Lemonldap::NG::Common::Cli');
|
||||
use_ok('Lemonldap::NG::Manager::Cli');
|
||||
|
@ -77,14 +77,6 @@ combined_like(
|
|||
'"Force cfgNum" OK'
|
||||
);
|
||||
|
||||
# Test 'set' command with nohistory
|
||||
@cmd = qw(-yes 1 -force 1 -nohistory 1 set cookieName test);
|
||||
combined_like(
|
||||
sub { llclient->run(@cmd) },
|
||||
qr#cfgNum forced with 6#s,
|
||||
'"Force cfgNum" OK'
|
||||
);
|
||||
|
||||
# Test 'info' command with force
|
||||
@cmd = qw(info);
|
||||
combined_like(
|
||||
|
|
Loading…
Reference in New Issue
Block a user