Ignore:
Timestamp:
10/01/19 19:16:21 (5 years ago)
Author:
nanardon
Message:

Add lock/banpasswd functions

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Base.pm

    r2278 r2285  
    430430=cut 
    431431 
    432 sub base { $_[0]->Context->base } 
    433 sub term { $_[0]->Context->Term } 
    434 sub print { shift->Context->print(@_) } 
     432sub La           { $_[0]->Context->La   } 
     433sub base         { $_[0]->Context->base } 
     434sub term         { $_[0]->Context->Term } 
     435sub Interractive { $_[0]->Context->Interactive } 
     436sub print        { shift->Context->print(@_) } 
    435437 
    436438sub Top { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Context.pm

    r2245 r2285  
    3333has TransStarted => ( is => 'rw', isa => 'Bool', default => 0 ); 
    3434has base => ( is => 'ro' ); 
     35has La => ( is => 'ro' ); 
    3536has Out => ( is => 'ro' ); 
     37has Interractive => ( is => 'rw', isa => 'Bool', default => 1 ); 
    3638 
    3739=head1 FUNCTIONS 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Cli/Object.pm

    r2267 r2285  
    422422 
    423423    if (lc($self->otype) eq 'user') { 
     424 
     425=head2 USER OBJECT FUCNTION 
     426 
     427=cut 
     428 
    424429        $self->add_func('group', { 
    425430            help => 'group add|remove|primary goupname', 
     
    476481            }, 
    477482        }); 
     483 
     484=head3 lock 
     485 
     486Lock user account making it not usable 
     487 
     488=cut 
     489 
     490        $self->add_func('lock', { 
     491            code => sub { 
     492                my ( $env, $ban ) = @_; 
     493                foreach my $obj (@{$env->{_objects}}) { 
     494                    $obj->set_c_fields('locked', 1); 
     495                    if ($ban) { 
     496                        $obj->banCurrentPassword; 
     497                    } 
     498                } 
     499                $env->commit; 
     500            }, 
     501            completion => sub { 
     502                if (!$_[2]) { 
     503                    return (qw(ban)); 
     504                } 
     505            }, 
     506        }); 
     507 
     508=head3 unlock 
     509 
     510Unlock user account making it usable again 
     511 
     512=cut 
     513 
     514        $self->add_func('unlock', { 
     515            code => sub { 
     516                my ( $env, $ban ) = @_; 
     517                foreach my $obj (@{$env->{_objects}}) { 
     518                    $obj->set_c_fields('locked', undef); 
     519                    if ($ban) { 
     520                        $obj->banCurrentPassword; 
     521                    } 
     522                } 
     523                $env->commit; 
     524            }, 
     525            completion => sub { 
     526                if (!$_[2]) { 
     527                    return (qw(ban)); 
     528                } 
     529            }, 
     530        }); 
     531 
     532=head3 banpasswd 
     533 
     534Ban current pasword making it not usable by user 
     535 
     536=cut 
     537 
     538        $self->add_func('banpasswd', { 
     539            code => sub { 
     540                my ( $env, $ban ) = @_; 
     541                foreach my $obj (@{$env->{_objects}}) { 
     542                    $obj->banCurrentPassword; 
     543                } 
     544                $env->commit; 
     545            }, 
     546            completion => sub {}, 
     547        }); 
     548 
    478549    } elsif ($self->otype eq 'group') { 
     550 
     551=head2 GROUP OBJECT FUNCTIONS 
     552 
     553=cut 
     554 
    479555        $self->add_func('member', { 
    480556            help => 'member add|remove user', 
Note: See TracChangeset for help on using the changeset viewer.