line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
App::LedgerSMB::Admin::User - Administer LedgerSMB Users with DB Admin Tools |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=cut |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package App::LedgerSMB::Admin::User; |
8
|
1
|
|
|
1
|
|
1332
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
with 'PGObject::Simple::Role'; |
10
|
1
|
|
|
1
|
|
298
|
use PGObject::Util::DBMethod; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
272
|
|
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
|
sub _get_dbh { $_[0]->connect } |
13
|
0
|
|
|
0
|
|
|
sub _get_prefix { 'admin__' } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNPOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use App::LedgerSMB::Admin; |
18
|
|
|
|
|
|
|
use App::LedgerSMB::Admin::User; |
19
|
|
|
|
|
|
|
use App::LedgerSMB::Admin::Database; |
20
|
|
|
|
|
|
|
App::LedgerSMB::Admin->add_paths( |
21
|
|
|
|
|
|
|
1.3 => '/usr/local/ledgersmb' |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
my $user = App::LedgerSMB::Admin::User->new( |
24
|
|
|
|
|
|
|
pls_import => 0, |
25
|
|
|
|
|
|
|
first_name => 'Chris', |
26
|
|
|
|
|
|
|
last_name => 'Travers', |
27
|
|
|
|
|
|
|
is_employee => 0, |
28
|
|
|
|
|
|
|
is_person => 1, |
29
|
|
|
|
|
|
|
username => 'chris', |
30
|
|
|
|
|
|
|
temp_pass => 'foobarbaz', |
31
|
|
|
|
|
|
|
country_id => '232', |
32
|
|
|
|
|
|
|
database => App::LedgerSMB::Admin::Database->new( |
33
|
|
|
|
|
|
|
dbname => 'lsmb13', |
34
|
|
|
|
|
|
|
username => 'postgres', |
35
|
|
|
|
|
|
|
password => 'secret', |
36
|
|
|
|
|
|
|
host => 'localhost', |
37
|
|
|
|
|
|
|
port => '5432', |
38
|
|
|
|
|
|
|
), |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
$user->assign_roles($user->list_roles); |
41
|
|
|
|
|
|
|
$user->save; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 PROPERTIES |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 database |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The database object associated with this object. Must be an object of type |
48
|
|
|
|
|
|
|
App::LedgerSMB::Admin::Database. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'database' => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => sub { |
55
|
|
|
|
|
|
|
die 'Must be of type App::LedgerSMB::Admin::Database' |
56
|
|
|
|
|
|
|
unless eval { $_[0]->isa('App::LedgerSMB::Admin::Database')}; |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 username |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has username => (is => 'ro'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 password |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has password => (is => 'ro'); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 first_name |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has first_name => (is => 'ro'); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 last_name |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has last_name => (is => 'ro'); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 middle_name |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has middle_name => (is => 'ro'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 dob |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Date of birth |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
has dob => (is => 'ro'); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 ssn |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Social security number or tax id. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has ssn => (is => 'ro'); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 is_employee |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
bool, is true if we need to create an employee record when we save. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has is_employee => ( |
113
|
|
|
|
|
|
|
is => 'ro', |
114
|
|
|
|
|
|
|
isa => sub { |
115
|
|
|
|
|
|
|
die 'invalid bool' |
116
|
|
|
|
|
|
|
unless 1 == scalar grep {$_[0] = $_} |
117
|
|
|
|
|
|
|
(undef, 0, 1, 't', 'f', 'true', 'false') |
118
|
|
|
|
|
|
|
}, |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 entity_id |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 id |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
has entity_id => (is => 'ro'); |
128
|
|
|
|
|
|
|
has id => (is => 'ro'); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 METHODS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 get |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
dbmethod get => (funcname => 'get_user'); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 reset_passwd |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
dbmethod reset_password => (funcname => 'save_user'); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright 2014 Chris Travers. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is distributed under the (Revised) BSD License: |
149
|
|
|
|
|
|
|
L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without |
152
|
|
|
|
|
|
|
modification, are permitted provided that the following conditions |
153
|
|
|
|
|
|
|
are met: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright |
156
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright |
159
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the |
160
|
|
|
|
|
|
|
documentation and/or other materials provided with the distribution. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
* Neither the name of Chris Travers's Organization |
163
|
|
|
|
|
|
|
nor the names of its contributors may be used to endorse or promote |
164
|
|
|
|
|
|
|
products derived from this software without specific prior written |
165
|
|
|
|
|
|
|
permission. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
168
|
|
|
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
169
|
|
|
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
170
|
|
|
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
171
|
|
|
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
172
|
|
|
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
173
|
|
|
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
174
|
|
|
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
175
|
|
|
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
176
|
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
177
|
|
|
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |