Finish the login function.