line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PAIA::Command::change; |
2
|
4
|
|
|
4
|
|
1539
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
155
|
|
3
|
4
|
|
|
4
|
|
52
|
use v5.10; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
117
|
|
4
|
4
|
|
|
4
|
|
12
|
use parent 'App::PAIA::Command'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
65
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.30'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _execute { |
9
|
0
|
|
|
0
|
|
|
my ($self, $opt, $args) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
0
|
|
|
|
my $auth = $self->auth // $self->usage_error("missing PAIA auth URL"); |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my %params = ( |
14
|
|
|
|
|
|
|
patron => $self->patron, |
15
|
|
|
|
|
|
|
username => $self->username, |
16
|
|
|
|
|
|
|
old_password => $self->password, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$self->auto_login_for('change'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Password should not be given as command line option, but as input |
22
|
|
|
|
|
|
|
# TODO: better way to get a new password, without echoing |
23
|
|
|
|
|
|
|
# e.g. use Term::ReadKey (ReadMode('noecho')) or TermTerm::ReadPassword |
24
|
|
|
|
|
|
|
# See also App::Cmd::Plugin::Prompt or Term::ReadPassword |
25
|
|
|
|
|
|
|
{ |
26
|
0
|
|
|
|
|
|
print "new password: "; |
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
chomp(my $pwd = scalar ); |
28
|
0
|
0
|
|
|
|
|
if (length($pwd) < 4) { |
29
|
0
|
|
|
|
|
|
say "your password is too short!"; |
30
|
0
|
|
|
|
|
|
redo; |
31
|
|
|
|
|
|
|
} else { |
32
|
0
|
|
|
|
|
|
print "please repeat: "; |
33
|
0
|
|
|
|
|
|
chomp(my $pwd2 = scalar ); |
34
|
0
|
0
|
|
|
|
|
if ($pwd2 ne $pwd) { |
35
|
0
|
|
|
|
|
|
say "passwords don't match!"; |
36
|
0
|
|
|
|
|
|
redo; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
$params{new_password} = $pwd; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->request( "POST", "$auth/change", \%params ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |