Bug 20434: Update UNIMARC framework - auth (TM)
[koha.git] / Koha / Exceptions / Password.pm
blobc7203c8886523a1ee0195c224e56510db7c05dec
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 under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 use Modern::Perl;
20 use Exception::Class (
22 'Koha::Exceptions::Password' => {
23 description => 'Something went wrong!',
25 'Koha::Exceptions::Password::Invalid' => {
26 isa => 'Koha::Exceptions::Password',
27 description => 'Invalid password'
29 'Koha::Exceptions::Password::TooShort' => {
30 isa => 'Koha::Exceptions::Password',
31 description => 'Password is too short',
32 fields => ['length','min_length']
34 'Koha::Exceptions::Password::TooWeak' => {
35 isa => 'Koha::Exceptions::Password',
36 description => 'Password is too weak'
38 'Koha::Exceptions::Password::WhitespaceCharacters' => {
39 isa => 'Koha::Exceptions::Password',
40 description => 'Password contains leading/trailing whitespace character(s)'
44 sub full_message {
45 my $self = shift;
47 my $msg = $self->message;
49 unless ( $msg) {
50 if ( $self->isa('Koha::Exceptions::Password::TooShort') ) {
51 $msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length );
55 return $msg;
58 =head1 NAME
60 Koha::Exceptions::Password - Base class for password exceptions
62 =head1 Exceptions
64 =head2 Koha::Exceptions::Password
66 Generic password exception
68 =head2 Koha::Exceptions::Password::Invalid
70 The supplied password is invalid.
72 =head2 Koha::Exceptions::Password::TooShort
74 Password is too short.
76 =head2 Koha::Exceptions::Password::TooWeak
78 Password is too weak.
80 =head2 Koha::Exceptions::Password::WhitespaceCharacters
82 Password contains leading/trailing spaces, which is forbidden.
84 =head1 Class methods
86 =head2 full_message
88 Overloaded method for exception stringifying.
90 =cut