refactor login and logout
refactor login and logout