Add login functions and related codes