Refactored authorisation code in separate module