Bug 20854: (QA follow-up) Improve readability
The logout_cas method does too little tasks. In this case, I consider we should not split it into a separate method. As the CAS implementation lacked tests, it made sense to do it like this, so it is testable. But now we have higher-level tests for logout_cas, we can bake the behavior inside of it, and it is testable. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commit7c3c066714) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit9b3538678e) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
2cccd4bfee
commit
1fdfc367fb
|
|
@ -68,14 +68,21 @@ sub getMultipleAuth {
|
|||
|
||||
# Logout from CAS
|
||||
sub logout_cas {
|
||||
my ($query, $type) = @_;
|
||||
my ( $cas, $uri ) = _get_cas_and_service($query, undef, $type);
|
||||
$uri =~ s/\?logout\.x=1//; # We don't want to keep triggering a logout, if we got here, the borrower is already logged out of Koha
|
||||
my $logout_url = $cas->logout_url(url => $uri);
|
||||
$logout_url = _fix_logout_url($logout_url);
|
||||
print $query->redirect( $logout_url );
|
||||
my ( $query, $type ) = @_;
|
||||
my ( $cas, $uri ) = _get_cas_and_service( $query, undef, $type );
|
||||
|
||||
# We don't want to keep triggering a logout, if we got here,
|
||||
# the borrower is already logged out of Koha
|
||||
$uri =~ s/\?logout\.x=1//;
|
||||
|
||||
my $logout_url = $cas->logout_url( url => $uri );
|
||||
$logout_url =~ s/url=/service=/
|
||||
if C4::Context->preference('casServerVersion') eq '3';
|
||||
|
||||
print $query->redirect($logout_url);
|
||||
}
|
||||
|
||||
|
||||
# Login to CAS
|
||||
sub login_cas {
|
||||
my ($query, $type) = @_;
|
||||
|
|
@ -206,15 +213,6 @@ sub _get_cas_and_service {
|
|||
return ( $cas, $uri );
|
||||
}
|
||||
|
||||
# Fix the logout URL when the cas server is 3.0 or superior
|
||||
sub _fix_logout_url {
|
||||
my $url = shift;
|
||||
if (C4::Context->preference('casServerVersion') eq '3') {
|
||||
$url =~ s/url=/service=/;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
# Get the current URL with parameters contained directly into URL (GET params)
|
||||
# This method replaces $query->url() which will give both GET and POST params
|
||||
sub _url_with_get_params {
|
||||
|
|
|
|||
Loading…
Reference in New Issue