Skip to content
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

Added missing update functionality #106

Merged
merged 1 commit into from
Feb 14, 2016

Conversation

Sega-Zero
Copy link
Contributor

As I mentioned in #103, there is a proper way to update values in keychain - SecItemUpdate function.

This pull request adds a new method updateInSecureStore. Instead of deleting and adding after, Locksmith.updateData now uses the new updateInSecureStore method. Delete&Add is error prone, IMHO, I've seen the cases, when deletion returned errSecSuccess, but the value still persisted in keychain. Which is why I, usually, set the value to empty and then delete it.

I didn't included the tests from #103, but if you would like to merge it too, the User class should be changed to something like this in order to pass the test:

public func store() -> Bool {
        do {
            try self.createInSecureStore()
        } catch LocksmithError.Duplicate {
            guard let _ = try? self.updateInSecureStore() else { return false }
            print("succesfully updated a value")
        } catch let error {
            print("Couldn't store: \(error)")
            return false
        }
        return true
    }

Not sure if catching .Duplicate is a good way, maybe one should implement find method to ensure no value exists before trying to call createInSecureStore

…eInSecureStore method to CreateableSecureStorable
@matthewpalmer matthewpalmer mentioned this pull request Feb 14, 2016
@matthewpalmer matthewpalmer merged commit e04d629 into matthewpalmer:master Feb 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants