(refactor) Complete user login and logout flow