complete the login function
login function