Skip to content

Commit

Permalink
Merge pull request #1122 from RotherOSS/issue-#1106-customer_pl
Browse files Browse the repository at this point in the history
Issue #1106 customer pl
  • Loading branch information
bschmalhofer authored Jul 11, 2021
2 parents 2fc218e + 0ca68dd commit d348a60
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 70 deletions.
59 changes: 23 additions & 36 deletions Kernel/Output/HTML/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,9 @@ sub Login {
Value => $Param{LoginFailed},
);

# include the X-OTOBO-Login header field
$Param{XLoginHeader} = 1;

# TODO: Data contains unneeded keys
$Self->_AddHeadersToResponseOBject(
Data => \%Param,
# declare headers including the X-OTOBO-Login header field
$Self->_AddHeadersToResponseObject(
XLoginHeader => 1,
);

# create & return output
Expand Down Expand Up @@ -1586,9 +1583,9 @@ sub Header {
}
}

# TODO: Data contains unneeded keys
$Self->_AddHeadersToResponseOBject(
Data => \%Param,
$Self->_AddHeadersToResponseObject(
ContentDisposition => $Param{ContentDisposition},
DisableIFrameOriginRestricted => $Param{DisableIFrameOriginRestricted},
);

# create & return output
Expand All @@ -1600,35 +1597,22 @@ sub Header {

=begin Internal:
=head2 _AddHeadersToResponseOBject()
=head2 _AddHeadersToResponseObject()
basically the same thing as executing the formerly used template HTTPHeaders.tt
my $Success = $LayoutObject->_AddHeadersToResponseOBject(
my $Success = $LayoutObject->_AddHeadersToResponseObject(
Data => \%Params,
);
The cookies are also added here.
=cut

sub _AddHeadersToResponseOBject {
sub _AddHeadersToResponseObject {
my ( $Self, %Param ) = @_;

# check needed stuff
for (qw(Data)) {
if ( !$Param{$_} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $_!"
);

return;
}
}

# extract parames
my %Data = $Param{Data}->%*;
# there are no required parameters

# get singletons
my $ResponseObject = $Kernel::OM->Get('Kernel::System::Web::Response');
Expand All @@ -1643,8 +1627,8 @@ sub _AddHeadersToResponseOBject {
'Pragma' => 'no-cache',
);

if ( $Data{ContentDisposition} ) {
$Headers{'Content-Disposition'} = $Data{ContentDisposition};
if ( $Param{ContentDisposition} ) {
$Headers{'Content-Disposition'} = $Param{ContentDisposition};
}

if ( !$ConfigObject->Get('Secure::DisableBanner') ) {
Expand All @@ -1653,14 +1637,14 @@ sub _AddHeadersToResponseOBject {

if (
!$ConfigObject->Get('DisableIFrameOriginRestricted')
&& !$Data{DisableIFrameOriginRestricted}
&& !$Param{DisableIFrameOriginRestricted}
)
{
$Headers{'X-Frame-Options'} = 'SAMEORIGIN';
}

# With this X-Header, Core.AJAX can recognize that the AJAX request returned the login page (session timeout) and perform a redirect.
if ( $Data{'XLoginHeader'} ) {
if ( $Param{XLoginHeader} ) {
$Headers{'X-OTOBO-Login'} = $Self->{Baselink};
}

Expand Down Expand Up @@ -3951,9 +3935,8 @@ sub HumanReadableDataSize {
sub CustomerLogin {
my ( $Self, %Param ) = @_;

$Param{TitleArea} = $Self->{LanguageObject}->Translate('Login') . ' - ';
$Param{IsLoginPage} = 1;
$Param{XLoginHeader} = 1;
$Param{TitleArea} = $Self->{LanguageObject}->Translate('Login') . ' - ';
$Param{IsLoginPage} = 1;

# set Action parameter for the loader
$Self->{Action} = 'CustomerLogin';
Expand Down Expand Up @@ -4179,6 +4162,10 @@ sub CustomerLogin {
$Param{ColorDefinitions} .= "--col$Color:$ColorDefinitions->{ $Color };";
}

$Self->_AddHeadersToResponseObject(
XLoginHeader => 1,
);

# create & return output
return $Self->Output(
TemplateFile => 'CustomerLogin',
Expand Down Expand Up @@ -4302,9 +4289,9 @@ sub CustomerHeader {
$Param{ColorDefinitions} .= "--col$Color:$ColorDefinitions->{ $Color };";
}

# TODO: Data contains unneeded keys
$Self->_AddHeadersToResponseOBject(
Data => \%Param,
$Self->_AddHeadersToResponseObject(
ContentDisposition => $Param{ContentDisposition},
DisableIFrameOriginRestricted => $Param{DisableIFrameOriginRestricted},
);

# create & return output
Expand Down
20 changes: 11 additions & 9 deletions Kernel/System/Web/InterfaceAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
$QueryString =~ s/(\?|&|;|)$Param{SessionName}(=&|=;|=.+?&|=.+?$)/;/g;

# define framework params
my %FrameworkParams = (
Lang => '',
Action => '',
Subaction => '',
RequestedURL => $QueryString,
);
for my $Key ( sort keys %FrameworkParams ) {
$Param{$Key} = $ParamObject->GetParam( Param => $Key ) || $FrameworkParams{$Key};
{
my %FrameworkParams = (
Lang => '',
Action => '',
Subaction => '',
RequestedURL => $QueryString,
);
for my $Key ( sort keys %FrameworkParams ) {
$Param{$Key} = $ParamObject->GetParam( Param => $Key ) || $FrameworkParams{$Key};
}
}

# validate language
Expand Down Expand Up @@ -246,7 +248,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
# check request type
if ( $Param{Action} eq 'PreLogin' ) {
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
$Param{RequestedURL} = $Param{RequestedURL} || "Action=AgentDashboard";
$Param{RequestedURL} ||= 'Action=AgentDashboard';

# login screen
return $LayoutObject->Login(
Expand Down
50 changes: 25 additions & 25 deletions Kernel/System/Web/InterfaceCustomer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use utf8;
# CPAN modules

# OTOBO modules
use Kernel::System::Email;
use Kernel::System::VariableCheck qw(IsArrayRefWithData IsHashRefWithData);
use Kernel::Language qw(Translatable);
use Kernel::System::DateTime;
Expand All @@ -41,7 +40,7 @@ our @ObjectDependencies = (
'Kernel::System::CustomerGroup',
'Kernel::System::CustomerUser',
'Kernel::System::DB',
'Kernel::System::Group',
'Kernel::System::Email',
'Kernel::System::Log',
'Kernel::System::Main',
'Kernel::System::Scheduler',
Expand Down Expand Up @@ -107,7 +106,7 @@ sub new {
# register object params
$Kernel::OM->ObjectParamAdd(
'Kernel::System::Log' => {
LogPrefix => $Kernel::OM->Get('Kernel::Config')->Get('CGILogPrefix'),
LogPrefix => $Kernel::OM->Get('Kernel::Config')->Get('CGILogPrefix') || 'Customer',
},
'Kernel::System::Web::Request' => {
PSGIEnv => $Param{PSGIEnv} || 0,
Expand Down Expand Up @@ -165,15 +164,16 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
$QueryString =~ s/(\?|&|;|)$Param{SessionName}(=&|=;|=.+?&|=.+?$)/;/g;

# define framework params
my $FrameworkParams = {
Lang => '',
Action => '',
Subaction => '',
RequestedURL => $QueryString,
};
for my $Key ( sort keys %{$FrameworkParams} ) {
$Param{$Key} = $ParamObject->GetParam( Param => $Key )
|| $FrameworkParams->{$Key};
{
my %FrameworkParams = (
Lang => '',
Action => '',
Subaction => '',
RequestedURL => $QueryString,
);
for my $Key ( sort keys %FrameworkParams ) {
$Param{$Key} = $ParamObject->GetParam( Param => $Key ) || $FrameworkParams{$Key};
}
}

# validate language
Expand Down Expand Up @@ -248,6 +248,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
# check request type
if ( $Param{Action} eq 'PreLogin' ) {
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
$Param{RequestedURL} ||= 'Action=CustomerDashboard';

# login screen
return $LayoutObject->CustomerLogin(
Expand Down Expand Up @@ -350,10 +351,10 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
if ( $ConfigObject->Get('CustomerPanelLoginURL') ) {
$Param{RequestedURL} = $LayoutObject->LinkEncode( $Param{RequestedURL} );

# throw a Kernel::System::Web::Exception that redirects
$LayoutObject->Redirect(
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL')
. "?Reason=LoginFailed&RequestedURL=$Param{RequestedURL}",
); # throws a Kernel::System::Web::Exception
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL') . "?Reason=LoginFailed&RequestedURL=$Param{RequestedURL}",
);
}

if ($PreventBruteForceConfig) {
Expand Down Expand Up @@ -416,10 +417,11 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)

# redirect to alternate login
if ( $ConfigObject->Get('CustomerPanelLoginURL') ) {

# throw a Kernel::System::Web::Exception that redirects
$LayoutObject->Redirect(
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL')
. '?Reason=SystemError',
); # throws a Kernel::System::Web::Exception
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL') . '?Reason=SystemError',
);
}

# show need user data error message
Expand Down Expand Up @@ -627,7 +629,6 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)

# redirect to alternate login
if ( $ConfigObject->Get('CustomerPanelLogoutURL') ) {

$LayoutObject->Redirect(
ExtURL => $ConfigObject->Get('CustomerPanelLogoutURL'),
); # throws a Kernel::System::Web::Exception
Expand Down Expand Up @@ -718,7 +719,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
}

# create email object
my $EmailObject = Kernel::System::Email->new( %{$Self} );
my $EmailObject = $Kernel::OM->Get('Kernel::System::Email');

# send password reset token
if ( !$Token ) {
Expand Down Expand Up @@ -967,7 +968,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
}

# send notify email
my $EmailObject = Kernel::System::Email->new( %{$Self} );
my $EmailObject = $Kernel::OM->Get('Kernel::System::Email');
my $Body = $ConfigObject->Get('CustomerPanelBodyNewAccount')
|| 'No Config Option found!';
my $Subject = $ConfigObject->Get('CustomerPanelSubjectNewAccount')
Expand Down Expand Up @@ -1161,8 +1162,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
# redirect to alternate login
if ( $ConfigObject->Get('CustomerPanelLoginURL') ) {
$LayoutObject->Redirect(
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL')
. '?Reason=SystemError',
ExtURL => $ConfigObject->Get('CustomerPanelLoginURL') . '?Reason=SystemError',
); # throws a Kernel::System::Web::Exception
}

Expand Down Expand Up @@ -1423,7 +1423,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)
return $Output;
}

# throw exception
# throws a Kernel::System::Web::Exception
my %Data = $SessionObject->GetSessionIDData(
SessionID => $Param{SessionID},
);
Expand All @@ -1439,7 +1439,7 @@ sub Content { ## no critic qw(Subroutines::RequireFinalReturn)

$LayoutObject->CustomerFatalError(
Comment => Translatable('Please contact the administrator.'),
); # throws a Kernel::System::Web::Exception
);
}

=begin Internal:
Expand Down

0 comments on commit d348a60

Please sign in to comment.