Finish login function.