Adding a sign-out button
Now that we've added a sign-in feature to our app, we need to give our users a way to sign out as well. Most apps that deal with authenticating users will put a sign-out button somewhere in an account settings or profile screen. Since our app does not have an account settings or profile screen, we'll simply add a Sign out button to the navigation bar on the main page. In addition to allowing the user to sign out, the app should also automatically sign the user out if it receives any 401
(unauthorized) responses from the API.
We'll add support for automatic sign-out first, because we'll be able to repurpose it when we add the sign-out button:
- First, add a new
Action
property to theITripLogDataService
interface namedUnauthorizedDelegate
. This delegate will work like theAuthorizedDelegate
we added earlier in the chapter, except this one will allow callers to take action whenever the app's access to the data service is unauthorized...