Bug 22071: (follow-up) Simplify code
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 7 Jan 2019 10:31:43 +0000 (07:31 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 4 Jan 2019 03:13:39 +0000 (03:13 +0000)
commit0d5058b7b29d90cc7c8e533ee56388fbb5a96d52
treeb2a2fd42ce4c019e690e0ece0b34ad004627e3ef
parent613a0034e08af84af1e2198156bbfc6900ba6551
Bug 22071: (follow-up) Simplify code

In order to add features to this method, the current code would force us
to do it for each authentication method.

There's duplicated code that could be simplified. This patch makes the
authentication code just set $user on each block (oauth and cookie
authentication) and moves the final permissions check to the end of the
authenticate_api_request method.

Overall, the behaviour remains unchanged.

To test:
- Run:
  $ kshell
 k$ prove t/db_dependent/api/v1/auth_authenticate_api_request.t \
          t/db_dependent/api/v1/oauth.t
=> SUCCESS: Tests pass! Nothing changed!
- Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/REST/V1/Auth.pm