Move the authorization check into the library

- Reduces duplicated code (+)
- Makes the libary depend on the front-end for the is_pkg_admin function (-)
- Less logic in the controllers (+)
- Adjust is_pkg_admin calls to provide the user
- Adjust unit-tests accordingly