Bug 24018

Summary: No need to die "Not logged in"
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: 1joynelson, black23, m.de.rooy
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00
Circulation function:
Bug Depends on: 18403, 20489    
Bug Blocks:    
Attachments: Bug 24018: Remove die "Not logged in"
Bug 24018: Remove die "Not logged in"
Bug 24018: Remove die "Not logged in"
Bug 24018: Remove die "Not logged in"

Description Jonathan Druart 2019-11-12 15:03:27 UTC
There is a wrong pattern in several controller files:

my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";

This has been introduced by
  commit cee2cf9ff927504f9c24f6519462a7d702c5c27d
  Bug 18403: Add sub output_and_exit_if_error - unknown_patron & cannot_see_patron_infos

Which noted:
    Note that the 'or die "Not logged in";' part should not be needed, but... who trusts
    C4::Auth?
    I think it could be used as a safeguard later. I am willing to sed and remove  them
    if required.

Since we prevent DB user login it's no longer needed.
It is time to remove it, as we trust our code (don't you?) and it can be confusing.
Comment 1 Jonathan Druart 2019-11-12 15:22:02 UTC
Created attachment 95328 [details] [review]
Bug 24018: Remove die "Not logged in"
Comment 2 Michal Denar 2020-01-09 22:28:43 UTC
Jonathan, can you rebasi this patch on master?

Thank you.
Comment 3 Jonathan Druart 2020-01-10 08:32:26 UTC
Created attachment 97160 [details] [review]
Bug 24018: Remove die "Not logged in"
Comment 4 Michal Denar 2020-01-10 16:20:21 UTC
Created attachment 97232 [details] [review]
Bug 24018: Remove die "Not logged in"

Signed-off-by: Michal Denar <black23@gmail.com>
Comment 5 Marcel de Rooy 2020-01-17 08:06:21 UTC
Created attachment 97476 [details] [review]
Bug 24018: Remove die "Not logged in"

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 6 Marcel de Rooy 2020-01-17 08:09:12 UTC
Note: I checked a number of edits to see which call was preceding the find or die statement. In the very most cases it is a get_template_and_user. In members/mod_debarment.pl it was a checkauth call. I saw it twice. This should be fine especially since a flagsrequired is passed too.
Comment 7 Martin Renvoize (ashimema) 2020-01-20 14:04:30 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 8 Joy Nelson 2020-01-31 23:29:51 UTC
Does not apply to 19.11.x branch.  Please rebase if needed.