line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::MuForm::Field::Password; |
2
|
|
|
|
|
|
|
# ABSTRACT: password field |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
776
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
extends 'Data::MuForm::Field::Text'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has '+password' => ( default => 1 ); |
9
|
0
|
|
|
0
|
0
|
0
|
sub build_input_type { 'password' } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $class_messages = { |
12
|
|
|
|
|
|
|
'required' => 'Please enter a password in this field', |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_class_messages { |
16
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
17
|
|
|
|
|
|
|
my $messages = { |
18
|
1
|
|
|
|
|
1
|
%{ $self->next::method }, |
|
1
|
|
|
|
|
7
|
|
19
|
|
|
|
|
|
|
%$class_messages, |
20
|
|
|
|
|
|
|
}; |
21
|
1
|
|
|
|
|
10
|
return $messages; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
after 'field_validate' => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if ( !$self->required && !( defined( $self->value ) && length( $self->value ) ) ) { |
29
|
|
|
|
|
|
|
$self->no_update(1); |
30
|
|
|
|
|
|
|
$self->clear_errors; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub validate { |
35
|
4
|
|
|
4
|
1
|
4
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
6
|
$self->no_update(0); |
38
|
4
|
|
|
|
|
13
|
$self->next::method; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=encoding UTF-8 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Data::MuForm::Field::Password - password field |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
version 0.04 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The password field has a default minimum length of 6, which can be |
61
|
|
|
|
|
|
|
easily changed: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has_field 'password' => ( type => 'Password', minlength => 7 ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
It does not come with additional default checks, since password |
66
|
|
|
|
|
|
|
requirements vary so widely. There are a few constraints in the |
67
|
|
|
|
|
|
|
L<Data::MuForm::Types> modules which could be used with this |
68
|
|
|
|
|
|
|
field: NoSpaces, WordChars, NotAllDigits. |
69
|
|
|
|
|
|
|
These constraints can be used in the field definitions 'apply': |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use Data::MuForm::Types ('NoSpaces', 'WordChars', 'NotAllDigits' ); |
72
|
|
|
|
|
|
|
... |
73
|
|
|
|
|
|
|
has_field 'password' => ( type => 'Password', |
74
|
|
|
|
|
|
|
apply => [ NoSpaces, WordChars, NotAllDigits ], |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
If a password field is not required and nothing has been submitted, |
78
|
|
|
|
|
|
|
then the field will be marked 'no_update' to keep from overwriting a |
79
|
|
|
|
|
|
|
password in the database will a null. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Gerda Shank |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gerda Shank. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
90
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |