| 1 | package Elive::Entity::User; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 32 | ▶ | use warnings; use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 32 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 32 | ▶ | use Mouse::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 32 | extends 'Elive::Entity'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 32 | ▶ | use Elive::Entity::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 32 | ▶ | use Elive::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 32 | __PACKAGE__->entity_name('User'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 32 | __PACKAGE__->collection_name('Users'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 32 | has 'userId' => (is => 'rw', isa => 'Str', required => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | documentation => 'user identifier (numeric, unless LDAP configured)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 32 | __PACKAGE__->primary_key('userId'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 32 | __PACKAGE__->params(userName => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 32 | has 'deleted' => (is => 'rw', isa => 'Bool'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 32 | has 'loginPassword' => (is => 'rw', isa => 'Str'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | has 'loginName' => (is => 'rw', isa => 'Str', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | documentation => 'login name - must be unique'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 32 | has 'email' => (is => 'rw', isa => 'Str', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | documentation => 'users email address'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 32 | has 'role' => (is => 'rw', isa => 'Elive::Entity::Role', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | documentation => 'default user role', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | coerce => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 32 | has 'firstName' => (is => 'rw', isa => 'Str', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | documentation => 'users given name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 32 | has 'lastName' => (is => 'rw', isa => 'Str', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | documentation => 'users surname'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # 'groups' and 'domain' propreties made a brief appearence in Elm 9.5.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # but haven't survived past 9.5.2. Will cull these shortly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 32 | has 'groups' => (is => 'rw', isa => 'Any', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | documentation => 'groups that this user belongs to?'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 32 | has 'domain' => (is => 'rw', isa => 'Any', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | documentation => 'groups that this user belongs to?'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 314 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 314 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 314 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 314 | ▶ | if (defined $spec && ! ref $spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $spec and not ref $spec
MC/DC50%1/2
defined $spec and not ref $spec
defined $spec
not ref $spec
Truth table66%2/3
A and not(B)
A= defined $specB= not ref $spec
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 22 | %args = (userId => $spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 292 | %args = %$spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 314 | return \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | coerce 'Elive::Entity::User' => from 'HashRef|Str' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 179 | ▶ | => via {Elive::Entity::User->new($_)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Elive::Entity::User - Elluminate Users entity class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | This class is used to query and maintain information on registered Elluminate I<Live!> users. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | sub _readback_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 45 | ▶ | my ($class, $update_ref, $rows, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readback_check: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 45 | my %updates = %$update_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # password not included in readback record - skip it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 45 | delete $updates{loginPassword}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # retrieve can accept either a userId or loginName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | delete $updates{userId} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | if ($updates{userId} && @$rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | && exists $rows->[0]{loginName} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 45 | ▶ | && $updates{userId} eq $rows->[0]{loginName}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$updates{"userId"} and @$rows and exists $rows->[0]{"loginName"} and $updates{"userId"} eq $rows->[0]{"loginName"}
$updates{"userId"} and @$rows and exists $rows->[0]{"loginName"}
$updates{"userId"} and @$rows
MC/DC50%2/4
$updates{"userId"} and @$rows and exists $rows->[0]{"loginName"} and $updates{"userId"} eq $rows->[0]{"loginName"}
$updates{"userId"}
@$rows
exists $rows->[0]{"loginName"}
$updates{"userId"} eq $rows->[0]{"loginName"}
Truth table60%3/5
A and B and C and D
A= $updates{"userId"}B= @$rowsC= exists $rows->[0]{"loginName"}D= $updates{"userId"} eq $rows->[0]{"loginName"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 45 | return $class->SUPER::_readback_check(\%updates, $rows, @args, case_insensitive => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | =head2 get_by_loginName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | my $user = Elive::Entity::User->get_by_loginName('joebloggs'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | Retrieve on loginName, which is a co-key for the users table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | Please note that the Elluminate Web Services raise an error if the user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | was not found. So, if you're not sure if the user exists: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | my $user = try {Elive::Entity::User->get_by_loginName('joebloggs')}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sub get_by_loginName { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 14 | ▶ | my ($class, $loginName, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_by_loginName: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # The entity name is loginName, but the fetch key is userName. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 14 | my $results = $class->_fetch({userName => $loginName}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | @args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 14 | ▶ | return @$results && $results->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@$results && $results->[0]
MC/DC50%1/2
@$results && $results->[0]
@$results
$results->[0]
Truth table66%2/3
A && B
A= @$resultsB= $results->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =head2 insert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | my $new _user = Elive::Entity::User->insert({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | loginName => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | loginPassword => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | firstName => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | lastName => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | email => ..., | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | role => ${Elive::Entity::Role::PARTICIPANT}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | )}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Insert a new user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub _safety_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 | ▶ | my ($self, %opt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_safety_check: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 14 | ▶ | unless ($opt{force}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 11 | ▶ | my $connection = $opt{connection} || $self->connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt{'connection'} || $self->connection
MC/DC0%0/2
$opt{'connection'} || $self->connection
$opt{'connection'}
$self->connection
Truth table33%1/3
A || B
A= $opt{'connection'}B= $self->connection
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | or die "Not connected"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | ▶ | die "Cowardly refusing to update login user" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | if $self->userId eq $connection->login->userId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 10 | ▶ | die "Cowardly refusing to update system admin account for ".$self->loginName.": (pass force => 1 to override)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | if ($self->_db_data->role->stringify <= ${Elive::Entity::Role::SYSTEM_ADMIN}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =head2 update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | my $user_obj = Elive::Entity::user->retrieve($user_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | $user_obj->update(role => ${Elive::Entity::Role::SYSTEM_ADMIN}); # upgrade to an app admin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | $user_obj->lastName('Smith'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $user_obj->update(undef, force => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | Update an Elluminate user. Everything can be changed, other than userId. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | This includes the loginName. However loginNames must all remain unique. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | As a safeguard, you'll need to pass C<force =E<gt> 1> to update: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | (a) users with a Role Id of 0, i.e. system administrator accounts, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | (b) the login user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | ▶ | my ($self, $data_href, %opt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | $self->_safety_check(%opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | return $self->SUPER::update( $data_href, %opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | =head2 change_password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | Implements the C<changePassword> SDK method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my $user = Elive::Entity::User->retrieve($user_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | $user->change_password($new_password); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | This is equivalent to: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | my $user = Elive::Entity::User->retrieve($user_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $user->update({loginPassword => $new_password}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub change_password { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | my ($self, $new_password, %opt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_password: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | if (defined $new_password && $new_password ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $new_password and $new_password ne ""
MC/DC0%0/2
defined $new_password and $new_password ne ""
defined $new_password
$new_password ne ""
Truth table33%1/3
A and B
A= defined $new_passwordB= $new_password ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | $self->_safety_check(%opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | $self->SUPER::update({loginPassword => $new_password}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | command => 'changePassword', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | %opt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | =head2 delete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $user_obj->delete(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | $admin_user_obj->delete(force => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | Delete user objects. As a safeguard, you need to pass C<force =E<gt> 1> to delete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | system administrator accounts, or the login user. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | Note that a deleted user, will have its deleted property immediately set, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | but may remain accessible for a short period of time until garbage collected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | So to check for a deleted user: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | my $user = Elive::Entity::User->retrieve( $user_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | my $user_is_deleted = !$user || $user->deleted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 10 | ▶ | my ($self, %opt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 10 | $self->_safety_check(%opt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | return $self->SUPER::delete( %opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | =head1 RESTRICTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | Elluminate I<Live!> can be configured to use LDAP for user management and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | authentication. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | If LDAP is in use, the fetch and retrieve methods will continue to operate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | via the Elluminate SOAP command layer. User access becomes read-only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | The affected methods are: C<insert>, C<update>, C<delete> and C<change_password>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||