finish the login function.