extract login/logout/resume behaviors to handlers