|
|
@ -37,7 +37,12 @@ my @lock = (); |
|
|
|
my $now = DateTime->now; |
|
|
|
my $now = DateTime->now; |
|
|
|
|
|
|
|
|
|
|
|
foreach my $user ($a->users){ |
|
|
|
foreach my $user ($a->users){ |
|
|
|
my $date = $user->prop('ExpiresOn') || 'never'; |
|
|
|
my $pass = $user->prop('PasswordSet') || 'no'; |
|
|
|
|
|
|
|
if ($pass ne 'yes'){ |
|
|
|
|
|
|
|
print $user->key . ": Account already locked\n" if $debug; |
|
|
|
|
|
|
|
next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
my $date = $user->prop('ExpireLockOn') || 'never'; |
|
|
|
if ($date eq 'never'){ |
|
|
|
if ($date eq 'never'){ |
|
|
|
print $user->key . ": No expiration date set\n" if $debug; |
|
|
|
print $user->key . ": No expiration date set\n" if $debug; |
|
|
|
next; |
|
|
|
next; |
|
|
@ -66,15 +71,23 @@ foreach my $user ($a->users){ |
|
|
|
# Lock accounts which need to be locked now |
|
|
|
# Lock accounts which need to be locked now |
|
|
|
foreach my $u (@lock){ |
|
|
|
foreach my $u (@lock){ |
|
|
|
event_signal('user-lock', $u); |
|
|
|
event_signal('user-lock', $u); |
|
|
|
$a->del_prop($u, 'ExpiresOn'); |
|
|
|
$a = esmith::AccountsDB->open || die "Couldn't open the AccountsDB\n"; |
|
|
|
$a->del_prop($u, 'ExpirationLastNotified'); |
|
|
|
my $rec = $a->get($u); |
|
|
|
|
|
|
|
my $fwd = $rec->prop('ExpireForwardAfterLock') || ''; |
|
|
|
|
|
|
|
if ($fwd ne ''){ |
|
|
|
|
|
|
|
$rec->set_prop('ForwardAddress', $fwd); |
|
|
|
|
|
|
|
$rec->set_prop('EmailForward', 'forward'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$rec->del_prop('ExpireLockOn'); |
|
|
|
|
|
|
|
$rec->del_prop('ExpireLastNotifiedOn'); |
|
|
|
|
|
|
|
$rec->set_prop('ExpireLockedOn', $now->ymd); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Send a warning for accounts which will be locked soon |
|
|
|
# Send a warning for accounts which will be locked soon |
|
|
|
my $send_warn_for = {}; |
|
|
|
my $send_warn_for = {}; |
|
|
|
foreach my $user (keys %$rem){ |
|
|
|
foreach my $user (keys %$rem){ |
|
|
|
my $rec = $a->get($user) || next; |
|
|
|
my $rec = $a->get($user) || next; |
|
|
|
my $last_notif = $rec->prop('ExpirationLastNotified') || 'never'; |
|
|
|
my $last_notif = $rec->prop('ExpireLastNotifiedOn') || 'never'; |
|
|
|
if ($last_notif =~ m/^(\d{4})\-(\d{1,2})\-(\d{1,2})/){ |
|
|
|
if ($last_notif =~ m/^(\d{4})\-(\d{1,2})\-(\d{1,2})/){ |
|
|
|
$last_notif = DateTime->new( |
|
|
|
$last_notif = DateTime->new( |
|
|
|
year => $1, |
|
|
|
year => $1, |
|
|
@ -107,7 +120,7 @@ foreach my $user (keys %$rem){ |
|
|
|
close QMAIL; |
|
|
|
close QMAIL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$rec->set_prop('ExpirationLastNotified', $now->ymd); |
|
|
|
$rec->set_prop('ExpireLastNotifiedOn', $now->ymd); |
|
|
|
# This one will be notified to the admin |
|
|
|
# This one will be notified to the admin |
|
|
|
$send_warn_for->{$user} = { |
|
|
|
$send_warn_for->{$user} = { |
|
|
|
remaining => $rem->{$user}, |
|
|
|
remaining => $rem->{$user}, |
|
|
|