Tidied up working out when to replace a 302 redirect with a 401 for auth