finish login and logout.