allow registration to be denied for certain IPs, e.g. known spammers

(yes, there are actually spambots flooding people with unsolicited
registration e-mails)
This commit is contained in:
Daniel Friesel 2021-08-20 22:52:02 +02:00
parent 64e20b50cf
commit 39ab6e57d3
2 changed files with 20 additions and 0 deletions

View file

@ -85,6 +85,22 @@ sub register {
return;
}
if ( my $registration_denylist
= $self->app->config->{registration}->{denylist} )
{
open( my $fh, "<", $registration_denylist )
or die("cannot open($registration_denylist)");
while ( my $line = <$fh> ) {
chomp $line;
if ( $ip eq $line ) {
close($fh);
$self->render( 'register', invalid => "denylist" );
return;
}
}
close($fh);
}
if ( my $error = $self->users->is_name_invalid( name => $user ) ) {
$self->render( 'register', invalid => $error );
return;

View file

@ -78,6 +78,10 @@
<p>Aus Sicherheitsgründen kann der Account nur nach Passworteingabe
gelöscht werden.</p>
% }
% elsif ($invalid eq 'denylist') {
<span class="card-title">Registrierung deaktiviert</span>
<p>Für diesen Zugang ist derzeit keine Registrierung möglich.</p>
% }
% else {
<span class="card-title">Fehler</span>
<p><%= $invalid %></p>