Koha/Koha/Exceptions/Password.pm
Agustin Moyano 52deed335e Bug 23816: (follow-up) Fix many things
This patch:
 * reverts changes on misc/admin/set_password.pl
 * makes category param mandatory for AuthUtils::is_valid_password and AuthUtils::generate_password
 * changes onboarding.pl to set category param in AuthUtils::is_valid_password
 * Completes t/db_dependent/AuthUtils.t and drops t/AuthUtils.t
 * Removes offending <input type="number"/> and replaces it by <input type="text" inputmode="numeric" pattern="[0-9]*"/>

https://bugs.koha-community.org/show_bug.cgi?id=23826

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-09 15:39:52 +02:00

100 lines
2.7 KiB
Perl

package Koha::Exceptions::Password;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Exception::Class (
'Koha::Exceptions::Password' => {
description => 'Something went wrong!',
},
'Koha::Exceptions::Password::Invalid' => {
isa => 'Koha::Exceptions::Password',
description => 'Invalid password'
},
'Koha::Exceptions::Password::TooShort' => {
isa => 'Koha::Exceptions::Password',
description => 'Password is too short',
fields => ['length','min_length']
},
'Koha::Exceptions::Password::TooWeak' => {
isa => 'Koha::Exceptions::Password',
description => 'Password is too weak'
},
'Koha::Exceptions::Password::WhitespaceCharacters' => {
isa => 'Koha::Exceptions::Password',
description => 'Password contains leading/trailing whitespace character(s)'
},
'Koha::Exceptions::Password::Plugin' => {
isa => 'Koha::Exceptions::Password',
description => 'The password was rejected by a plugin'
},
'Koha::Exceptions::Password::NoCategoryProvided' => {
isa => 'Koha::Exceptions::Password',
description => 'You must provide a patron\'s category to validate password\'s strength and length'
}
);
sub full_message {
my $self = shift;
my $msg = $self->message;
unless ( $msg) {
if ( $self->isa('Koha::Exceptions::Password::TooShort') ) {
$msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length );
}
}
return $msg;
}
=head1 NAME
Koha::Exceptions::Password - Base class for password exceptions
=head1 Exceptions
=head2 Koha::Exceptions::Password
Generic password exception
=head2 Koha::Exceptions::Password::Invalid
The supplied password is invalid.
=head2 Koha::Exceptions::Password::TooShort
Password is too short.
=head2 Koha::Exceptions::Password::TooWeak
Password is too weak.
=head2 Koha::Exceptions::Password::WhitespaceCharacters
Password contains leading/trailing spaces, which is forbidden.
=head1 Class methods
=head2 full_message
Overloaded method for exception stringifying.
=cut
1;