OmerFlame / SwiftRant

devRant API library made in Swift.
GNU General Public License v3.0
3 stars 1 forks source link

Missing logout functionality #2

Closed WilhelmOks closed 2 years ago

WilhelmOks commented 2 years ago

There seems to be no way to log out after a log in. I've looked up how you do it in the AltRant app and you remove the token from the keychain directly. Modifying the code a bit, this is what works for me now:

    let keychainWrapper = KeychainWrapper(
        serviceName: "SwiftRant",
        accessGroup: "SwiftRantAccessGroup"
    )

    let query: [String:Any] = [
        kSecClass as String: kSecClassGenericPassword,
        kSecReturnAttributes as String: true,
        kSecReturnData as String: true,
    ]

    keychainWrapper.removeAllKeys()
    SecItemDelete(query as CFDictionary)

I suggest to wrap it into a logout function in SwiftRant.

OmerFlame commented 2 years ago

Thank you! I will add it later today, including the missing documentation in the last issue.

OmerFlame commented 2 years ago

Sadly, my computer has issues with the Xcode toolchains and stuff, can you please make a pull request? I want to approve this change, it's pretty important.

WilhelmOks commented 2 years ago

I created the PR. Please make a new version after merging, so that it gets updated via SPM :)

OmerFlame commented 2 years ago

No problem.

OmerFlame commented 2 years ago

I've released a new version!