Refactor sign in and out process, remember whether user is signed in after app exit