- optimize code

- optimize the code to validate username and userpassword in loginHandler