implement login function by promise