Completes login and logout functionalities