line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Field::PasswordConf; |
2
|
|
|
|
|
|
|
# ABSTRACT: password confirmation |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Field::PasswordConf::VERSION = '0.40067'; |
4
|
3
|
|
|
3
|
|
1974
|
use HTML::FormHandler::Moose; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
extends 'HTML::FormHandler::Field::Text'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has '+widget' => ( default => 'Password' ); |
9
|
|
|
|
|
|
|
has '+password' => ( default => 1 ); |
10
|
|
|
|
|
|
|
has '+required' => ( default => 1 ); |
11
|
|
|
|
|
|
|
has 'password_field' => ( isa => 'Str', is => 'rw', default => 'password' ); |
12
|
|
|
|
|
|
|
has 'pass_conf_message' => ( isa => 'Str', is => 'rw' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $class_messages = { |
15
|
|
|
|
|
|
|
required => 'Please enter a password confirmation', |
16
|
|
|
|
|
|
|
pass_conf_not_matched => 'The password confirmation does not match the password', |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get_class_messages { |
20
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
21
|
|
|
|
|
|
|
my $messages = { |
22
|
2
|
|
|
|
|
4
|
%{ $self->next::method }, |
|
2
|
|
|
|
|
9
|
|
23
|
|
|
|
|
|
|
%$class_messages, |
24
|
|
|
|
|
|
|
}; |
25
|
2
|
50
|
|
|
|
66
|
$messages->{pass_conf_not_matched} = $self->pass_conf_message |
26
|
|
|
|
|
|
|
if $self->pass_conf_message; |
27
|
2
|
|
|
|
|
20
|
return $messages; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub validate { |
32
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
10
|
my $value = $self->value; |
35
|
3
|
|
100
|
|
|
73
|
my $password = $self->form->field( $self->password_field )->value || ''; |
36
|
3
|
100
|
|
|
|
15
|
if ( $password ne $self->value ) { |
37
|
2
|
|
|
|
|
14
|
$self->add_error( $self->get_message('pass_conf_not_matched') ); |
38
|
2
|
|
|
|
|
5
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
3
|
return 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
3
|
|
|
3
|
|
5317
|
use namespace::autoclean; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
29
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding UTF-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
HTML::FormHandler::Field::PasswordConf - password confirmation |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
version 0.40067 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This field needs to be declared after the related Password field (or more |
64
|
|
|
|
|
|
|
precisely it needs to come after the Password field in the list returned by |
65
|
|
|
|
|
|
|
the L<HTML::FormHandler/fields> method). |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 password_field |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Set this attribute to the name of your password field (default 'password') |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Customize error message 'pass_conf_not_matched' or 'required' |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has_field '_password' => ( type => 'PasswordConf', |
74
|
|
|
|
|
|
|
messages => { required => 'You must enter the password a second time' }, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |