Finish login function