Implemented login and logout logic