New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SIWA] Handle invalid Apple user #12549
Conversation
…ized, log out the account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! One small comment about how we're logging an error, and then my only other question is whether we should do this every time the app returns to the foreground instead of on every launch – I don't know the correct answer to that though. @astralbodies, any thoughts?
try SFHFKeychainUtils.deleteItem(forUsername: WPAppleIDKeychainUsernameKey, | ||
andServiceName: WPAppleIDKeychainUsernameKey) | ||
} catch { | ||
DDLogDebug("Error while removing Apple User ID: \(error)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to log this as an 'error'? If I'm reading correctly it could simply be that the user has never logged in using SIWA, so there just wouldn't be a keychain item for Apple so we'll be logging out "Error while removing..." on every launch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @frosty .
user has never logged in using SIWA, so there just wouldn't be a keychain item for Apple so we'll be logging out "Error while removing..." on every launch.
That is correct. That's why I used DDLogDebug
. But now I see that the actual message can be misleading. I can change it to be less alarming, maybe something like:
DDLogDebug("Unable to remove Apple User ID from keychain: \(error)")
I didn't want to not log it since there could be an actual error.
Hey @frosty . I'm going to go ahead and merge these PRs to streamline my branchiness. My next task is working with the same code, so if the log message is still not acceptable I'd be more than happy to change it in the next PR. |
Thanks @ScoutHarris! The error message is better. As an additional change, we could not log the message if it's just that no item was found (which is the main non-error state):
We can roll this into a future PR, if you think it makes sense :) |
Fixes #12399
Related WPAuth PR: wordpress-mobile/WordPressAuthenticator-iOS#137
This uses the WPAuth changes to:
To note, this only addresses the scenario in the testing steps, i.e. checking state on app launch. We're not yet actively listening for Apple ID disconnects (#12535). Stay tuned!
To test:
This should be tested on a real device for proper keychain handling.
checkAppleIDCredentialState: Unauthorized Apple ID. User signed out.
Update release notes:
RELEASE-NOTES.txt
if necessary.