update login and logout logic