Bug 19889: (follow-up) Fix few minor things
[koha.git] / Koha / Exceptions / Password.pm
blob9cf24f0db0d8cfd99f6bcaacb898ff0692424bc4
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>.
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)'
42 'Koha::Exceptions::Password::Plugin' => {
43 isa => 'Koha::Exceptions::Password',
44 description => 'The password was rejected by a plugin'
48 sub full_message {
49 my $self = shift;
51 my $msg = $self->message;
53 unless ( $msg) {
54 if ( $self->isa('Koha::Exceptions::Password::TooShort') ) {
55 $msg = sprintf("Password length (%s) is shorter than required (%s)", $self->length, $self->min_length );
59 return $msg;
62 =head1 NAME
64 Koha::Exceptions::Password - Base class for password exceptions
66 =head1 Exceptions
68 =head2 Koha::Exceptions::Password
70 Generic password exception
72 =head2 Koha::Exceptions::Password::Invalid
74 The supplied password is invalid.
76 =head2 Koha::Exceptions::Password::TooShort
78 Password is too short.
80 =head2 Koha::Exceptions::Password::TooWeak
82 Password is too weak.
84 =head2 Koha::Exceptions::Password::WhitespaceCharacters
86 Password contains leading/trailing spaces, which is forbidden.
88 =head1 Class methods
90 =head2 full_message
92 Overloaded method for exception stringifying.
94 =cut