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

getAccount after setAccount function does not respect regToken #50

Open
joonmanji opened this issue Sep 19, 2022 · 2 comments
Open

getAccount after setAccount function does not respect regToken #50

joonmanji opened this issue Sep 19, 2022 · 2 comments

Comments

@joonmanji
Copy link
Contributor

Hey there,

We are currently trying to upgrade from an old downloaded framework of Gigya and GigyaTfa to the new swift cocoapods.
However it seems like we are running into an issue with social auth login where we require additional params from the user.

when we call setAccount passing in regToken intead of UID, this getAccount call seems to fail: https://github.com/SAP/gigya-swift-sdk/blob/main/GigyaSwift/Global/Api/BusinessApiService.swift#L112

changing this line to

self?.getAccount(params: params, dataType: T.self, completion: completion)

seems to fix it but i'm not sure of the downstream ramifications of this change.

@sagishm
Copy link
Member

sagishm commented Sep 29, 2022

Hi,
It's looks like incorrect implementation, can you provide example of your code?
if you are using gigya.login(with: [provider]... you need to use the interruption handler to resolve the missing params.
Thanks,
Sagi

@joonmanji
Copy link
Contributor Author

    let gigya = Gigya.sharedInstance(MyCompanyGigyaAccount.self)
.....
.....
.....
    @objc func setAccount(
        _ params: [String: Any],
        resolve: @escaping RCTPromiseResolveBlock,
        reject: @escaping RCTPromiseRejectBlock
    ) {
        var callbackInvoked = false
        gigya.setAccount(with: params) { (result) in
            guard !callbackInvoked else {
                return
            }
            switch result {
            case .success(data: let account):
                do {
                    let jsonData = try JSONEncoder().encode(account)
                    let jsonString = String(data: jsonData, encoding: .utf8)
                    resolve(jsonString)
                    callbackInvoked = true
                } catch let error {
                    reject(
                        "GIGYA.SET.ACCOUNT.JSON.ERROR",
                        "Error encoding json payload",
                        error)
                    callbackInvoked = true
                }
            case .failure(let error):
                switch error {
                case .gigyaError(let data):
                    self.rejectGigyaError(data, error: error, reject: reject)
                default:
                    reject("GIGYA.LOGIN.ERROR", error.localizedDescription, error)
                }
                callbackInvoked = true
            }
        }
    }

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

No branches or pull requests

2 participants