Finish common login fuction.