Follow-up to #17289: resolved endless loop with login/logout