Skip to content

Conversation

AngeloStavrow
Copy link
Collaborator

Closes #8.

This PR handles persistence for logged-in state in two ways.

Via the Keychain

When logging in, the user's access token is saved to the Keychain; when logging out, that Keychain entry is destroyed. A helper method for fetching the token is also part of this work; all Keychain helpers live in the WriteFreelyModel extension.

Via UserDefaults

For non-sensitive data, we also want to persist state so that we can fetch tokens from the Keychain between app launches (since the WF client, which has a user property, is only kept in-memory). We therefore persist the isLoggedIn, server, and username properties in UserDefaults, and restore these values on launch.

@AngeloStavrow AngeloStavrow added this to the 1.0.0-beta milestone Aug 25, 2020
@AngeloStavrow AngeloStavrow requested a review from thebaer August 25, 2020 13:06
@AngeloStavrow AngeloStavrow self-assigned this Aug 25, 2020
Copy link
Member

@thebaer thebaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@AngeloStavrow AngeloStavrow merged commit d721fd7 into main Aug 27, 2020
@AngeloStavrow AngeloStavrow deleted the persist-token-to-keychain branch August 27, 2020 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Store user access token in the system Keychain
2 participants