Add login function and failed function