phase 2 for single page app implementation - refactured complete login procedure