Add enforceLoginCustom middleware. Use error function for error responses.