BUG Issue with login form failing to login in certain situations. Fixes issue #2424