Implement login function.