Changeset 248


Ignore:
Timestamp:
12/31/10 12:04:39 (13 years ago)
Author:
nanardon
Message:
  • don't hardcode admin password in admin tools (it has been changed)
Location:
server/trunk/admin
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/admin/bin/sophie_admin

    r34 r248  
    55require RPC::XML::Client; 
    66use Getopt::Long; 
     7use Term::ReadKey; 
    78 
    89GetOptions( 
     
    1011) or die "Wrong options"; 
    1112 
    12 require Data::Dumper; 
    13 my $xmlcli = RPC::XML::Client->new($server || 'http://127.0.0.1:3000/rpc'); 
     13ReadMode('noecho'); 
     14print "Enter password: "; 
     15my $password = ReadLine(0); 
     16ReadMode 0; 
     17print "\n"; 
     18chomp($password); 
    1419 
    15 my $res = $xmlcli->send_request('login', 'admin', 'toto'); 
     20my $xmlcli = RPC::XML::Client->new($server || 'http://sophie.zarb.org/rpc'); 
     21 
     22my $res = $xmlcli->send_request('login', 'admin', $password); 
    1623if (ref $res) { 
    1724    $xmlcli->request->header('cookie', $$res); 
  • server/trunk/admin/lib/Sophie/Cli.pm

    r212 r248  
    192192    my $env = __PACKAGE__->new({}, $base); 
    193193 
     194    $env->add_func('list_user', 
     195        { 
     196            code => sub { 
     197                my ($self, $match) = @_; 
     198                my $res = $self->xmlreq('admin.list_user', $match); 
     199                if ($res) { 
     200                    print $OUT (map { "$_\n" } @{ $res->value }); 
     201                } 
     202            } 
     203        } 
     204    ); 
     205    $env->add_func('delete_user', 
     206        { 
     207            code => sub { 
     208                my ($self, $match) = @_; 
     209                my $res = $self->xmlreq('admin.delete_user', $match); 
     210                if ($res) { 
     211                    print $OUT $res->value . "\n"; 
     212                } 
     213            }, 
     214            completion => sub { 
     215                my ($self, undef, @args) = @_; 
     216                my $res = $self->xmlreq( 
     217                    'admin.list_user'); 
     218                return @{$res->value}; 
     219            }, 
     220        } 
     221    ); 
     222    $env->add_func('set_password', 
     223        { 
     224            code => sub { 
     225                my ($self, $match, $password) = @_; 
     226                my $res = $self->xmlreq('admin.set_user_password', $match, 
     227                    $password); 
     228                if ($res) { 
     229                    print $OUT $res->value . "\n"; 
     230                } 
     231            }, 
     232            completion => sub { 
     233                my ($self, undef, $user) = @_; 
     234                if (!$user) { 
     235                my $res = $self->xmlreq( 
     236                    'admin.list_user'); 
     237                return @{$res->value}; 
     238                } else { return } 
     239            }, 
     240        } 
     241    ); 
    194242    $env->add_func('create_user', 
    195243        { 
     
    217265                my $res = $self->xmlreq( 
    218266                    'distrib.list', @args); 
    219                 return  map { $_ } @{$res->value}; 
     267                return @{$res->value}; 
    220268            }, 
    221269        }, 
Note: See TracChangeset for help on using the changeset viewer.