Skip to content

Commit

Permalink
Change URI sub-path to be derived from company
Browse files Browse the repository at this point in the history
Replaces the approach of having the session ID in the URI.

Also removes the need to have '?__action=root' from URL by using '__default'
action in erp.pm.
  • Loading branch information
ehuelsmann committed Nov 16, 2024
1 parent e9e1942 commit 9ff9aad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/LedgerSMB/Middleware/SessionStorage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ sub call {
my $res = shift;

if (! $self->inner_serialize) {
my $token = $env->{'lsmb.session'}->{token} ?
$env->{'lsmb.session'}->{token} . '/' : '';
my $token = $env->{'lsmb.session'}->{company_path} ?
$env->{'lsmb.session'}->{company_path} . '/' : '';
my $path = $self->cookie_path
? ($self->cookie_path . $token)
: LedgerSMB::PSGI::Util::cookie_path($env->{SCRIPT_NAME});
Expand Down
4 changes: 2 additions & 2 deletions lib/LedgerSMB/Scripts/erp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use strict;
use warnings;


=item root
=item __default
Displays the root document.
=cut

sub root {
sub __default {
my ($request) = @_;

$request->{title} = "LedgerSMB $request->{version} -- ".
Expand Down
7 changes: 5 additions & 2 deletions lib/LedgerSMB/Scripts/login.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use strict;
use warnings;

use HTTP::Status qw( HTTP_OK );
use Digest::MD5 qw( md5_hex );
use JSON::MaybeXS;

use LedgerSMB::PSGI::Util;
Expand Down Expand Up @@ -86,10 +87,12 @@ sub authenticate {
return $r;
}

my $token = $request->{_req}->env->{'lsmb.session'}->{token};
$request->{_req}->env->{'lsmb.session'}->{company_path} =
md5_hex( $r->{company} );
my $token = $request->{_req}->env->{'lsmb.session'}->{company_path};
return [ HTTP_OK,
[ 'Content-Type' => 'application/json' ],
[ qq|{ "target": "$token/erp.pl?__action=root" }| ]];
[ qq|{ "target": "$token/erp.pl" }| ]];
}


Expand Down

0 comments on commit 9ff9aad

Please sign in to comment.