Working login function.