complete the function of login and logout