refactor login so it's self contained in a single function will be useful in adding other password based login method such as ldap
refactor login so it's self contained in a single function will be useful in adding other password based login method such as ldap