my ($cluster_encoding) = $dbh->selectrow_array($query);
if ($cluster_encoding && ($cluster_encoding =~ m/^(?:UTF-?8|UNICODE)$/i) && ($encoding !~ m/^(?:UTF-?8|UNICODE)$/i)) {
- $error = $main::locale->text('Your PostgreSQL installationen uses UTF-8 as its encoding. Therefore you have to configure Lx-Office to use UTF-8 as well.');
+ $error = $main::locale->text('Your PostgreSQL installationen uses UTF-8 as its encoding. Therefore you have to configure kivitendo to use UTF-8 as well.');
}
$dbh->disconnect();
my %menustyle_map = ( xml => 'new', v4 => 'v3' );
$user_data{menustyle} = $menustyle_map{lc($user_data{menustyle} || '')} || $user_data{menustyle};
+ # The 'Win2000.css' stylesheet has been removed.
+ $user_data{stylesheet} = 'kivitendo.css' if ($user_data{stylesheet} || '') =~ m/win2000/i;
+
# Set default language if selected language does not exist (anymore).
$user_data{countrycode} = $::lx_office_conf{system}->{language} unless $user_data{countrycode} && -d "locale/$user_data{countrycode}";
$cookie = $sth->fetchrow_hashref;
$sth->finish;
- if (!$cookie || $cookie->{is_expired} || ($cookie->{ip_address} ne $ENV{REMOTE_ADDR})) {
+ # The session ID provided is valid in the following cases:
+ # 1. session ID exists in the database
+ # 2. hasn't expired yet
+ # 3. if form field '{AUTH}api_token' is given: form field must equal database column 'auth.session.api_token' for the session ID
+ # 4. if form field '{AUTH}api_token' is NOT given then: the requestee's IP address must match the stored IP address
+ $self->{api_token} = $cookie->{api_token} if $cookie;
+ my $api_token_cookie = $self->get_api_token_cookie;
+ my $cookie_is_bad = !$cookie || $cookie->{is_expired};
+ $cookie_is_bad ||= $api_token_cookie && ($api_token_cookie ne $cookie->{api_token}) if $api_token_cookie;
+ $cookie_is_bad ||= $cookie->{ip_address} ne $ENV{REMOTE_ADDR} if !$api_token_cookie;
+ if ($cookie_is_bad) {
$self->destroy_session();
$main::lxdebug->leave_sub();
return $cookie ? SESSION_EXPIRED : SESSION_NONE;
do_query($::form, $dbh, qq|INSERT INTO auth.session (id, ip_address, mtime) VALUES (?, ?, now())|, $session_id, $ENV{REMOTE_ADDR});
}
+ if ($self->{column_information}->has('api_token', 'session')) {
+ my ($stored_api_token) = $dbh->selectrow_array(qq|SELECT api_token FROM auth.session WHERE id = ?|, undef, $session_id);
+ do_query($::form, $dbh, qq|UPDATE auth.session SET api_token = ? WHERE id = ?|, $self->_create_session_id, $session_id) unless $stored_api_token;
+ }
+
my @values_to_save = grep { $_->{fetched} }
values %{ $self->{SESSION} };
if (@values_to_save) {
}
sub get_session_cookie_name {
- my $self = shift;
+ my ($self, %params) = @_;
- return $self->{cookie_name} || 'lx_office_erp_session_id';
+ $params{type} ||= 'id';
+ my $name = $self->{cookie_name} || 'lx_office_erp_session_id';
+ $name .= '_api_token' if $params{type} eq 'api_token';
+
+ return $name;
}
sub get_session_id {
return $session_id;
}
+sub get_api_token_cookie {
+ my ($self) = @_;
+
+ $::request->{cgi}->cookie($self->get_session_cookie_name(type => 'api_token'));
+}
+
sub session_tables_present {
$main::lxdebug->enter_sub();
["batch_printing", $locale->text("Batch Printing")],
["--others", $locale->text("Others")],
["email_bcc", $locale->text("May set the BCC field when sending emails")],
- ["config", $locale->text("Change Lx-Office installation settings (all menu entries beneath 'System')")],
+ ["config", $locale->text("Change kivitendo installation settings (all menu entries beneath 'System')")],
["admin", $locale->text("Administration (Used to access instance administration from user logins)")],
);