fixes #4522 Auto-login Broke

Fixed the issue and committed code for review please check it.