1 package Koha::Exceptions::Password;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Exception::Class (
24 'Koha::Exceptions::Password' => {
25 isa => 'Koha::Exception',
27 'Koha::Exceptions::Password::Invalid' => {
28 isa => 'Koha::Exceptions::Password',
29 description => 'Invalid password'
31 'Koha::Exceptions::Password::TooShort' => {
32 isa => 'Koha::Exceptions::Password',
33 description => 'Password is too short',
34 fields => ['length','min_length']
36 'Koha::Exceptions::Password::TooWeak' => {
37 isa => 'Koha::Exceptions::Password',
38 description => 'Password is too weak'
40 'Koha::Exceptions::Password::WhitespaceCharacters' => {
41 isa => 'Koha::Exceptions::Password',
42 description => 'Password contains leading/trailing whitespace character(s)'
44 'Koha::Exceptions::Password::Plugin' => {
45 isa => 'Koha::Exceptions::Password',
46 description => 'The password was rejected by a plugin'
48 'Koha::Exceptions::Password::NoCategoryProvided' => {
49 isa => 'Koha::Exceptions::Password',
50 description => 'You must provide a patron\'s category to validate password\'s strength and length'
57 my $msg = $self->message;
60 if ( $self->isa('Koha::Exceptions::Password::TooShort') ) {
61 $msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length );
70 Koha::Exceptions::Password - Base class for password exceptions
74 =head2 Koha::Exceptions::Password
76 Generic password exception
78 =head2 Koha::Exceptions::Password::Invalid
80 The supplied password is invalid.
82 =head2 Koha::Exceptions::Password::TooShort
84 Password is too short.
86 =head2 Koha::Exceptions::Password::TooWeak
90 =head2 Koha::Exceptions::Password::WhitespaceCharacters
92 Password contains leading/trailing spaces, which is forbidden.
98 Overloaded method for exception stringifying.