From: Moritz Bunkus Date: Thu, 6 Jun 2013 13:04:30 +0000 (+0200) Subject: console: um Spezifikation vom Client erweitert X-Git-Tag: release-3.1.0beta1~331^2~56 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=72033e2d36d055046a58fb19574ce293d53f65d6;p=kivitendo-erp.git console: um Spezifikation vom Client erweitert --- diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index f77493c2c..0a2a97f41 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -208,7 +208,10 @@ email_subject = kivitendo self test report email_template = templates/mail/self_test/status_mail.txt [console] -# autologin to use if none is given +# Automatic login will only work if both "client" and "login" are +# given. "client" can be a client's database ID or its name. "login" +# is simply a user's login name. +client = login = # autorun lines will be executed after autologin. @@ -226,9 +229,11 @@ history_file = users/console_history log_file = /tmp/kivitendo_console_debug.log [testing] - -# autologin to use if none is given -login = myxplace_standard +# Automatic login will only work if both "client" and "login" are +# given. "client" can be a client's database ID or its name. "login" +# is simply a user's login name. +client = +login = [devel] # Several settings related to the development of kivitendo. diff --git a/scripts/console b/scripts/console index 32bebabf2..8ce978346 100755 --- a/scripts/console +++ b/scripts/console @@ -19,6 +19,7 @@ use Term::ReadLine::Perl::Bind; # use sane key binding for rxvt users use SL::LxOfficeConf; SL::LxOfficeConf->read; +my $client = $::lx_office_conf{console}{client}; my $login = $::lx_office_conf{console}{login} || 'demo'; my $history_file = $::lx_office_conf{console}{history_file} || '/tmp/kivitendo_console_history.log'; # fallback if users is not writable my $debug_file = $::lx_office_conf{console}{log_file} || '/tmp/kivitendo_console_debug.log'; @@ -27,6 +28,7 @@ my ($execute_code, $execute_file, $help, $man); my $result = GetOptions( "login|l=s" => \$login, + "client|c=s" => \$client, "history-file|i=s" => \$history_file, "log-file|o=s" => \$debug_file, "execute|e=s" => \$execute_code, @@ -61,8 +63,8 @@ my $repl = Devel::REPL->new; $repl->load_plugin($_) for @plugins; $repl->load_history($history_file); $repl->eval('help'); -$repl->print("trying to auto login as '$login'..."); -$repl->print($repl->eval("lxinit '$login'")); +$repl->print("trying to auto login into client '$client' with login '$login'...\n"); +execute_code($repl, "lxinit '$client', '$login'"); my @code_to_execute = grep { $_ } ($autorun, $execute_code, $execute_file ? join('', read_file($execute_file)) : undef); execute_code($repl, $_) || exit 1 for @code_to_execute; @@ -89,9 +91,9 @@ use List::Util qw(max); # it is assumed that anyone with physical access and execution rights on this script # won't be hindered by authentication anyway. sub lxinit { - my $login = shift; + my ($client, $login) = @_; - die 'need login' unless $login; + die 'need client and login' unless $client && $login; package main; @@ -99,6 +101,8 @@ sub lxinit { $::locale = Locale->new($::lx_office_conf{system}->{language}); $::form = Form->new; $::auth = SL::Auth->new; + die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client); + $::instance_conf = SL::InstanceConfiguration->new; $::request = SL::Request->new( cgi => CGI->new({}),