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

Refresh token still encrypted when sending to API #74

Open
timoinutilis opened this issue May 28, 2024 · 0 comments
Open

Refresh token still encrypted when sending to API #74

timoinutilis opened this issue May 28, 2024 · 0 comments

Comments

@timoinutilis
Copy link

The token refresh is broken, because "accessTokenModel.refresh_token" is still encrypted when using in "self.getAccessToken(refreshToken: ..."
It's only uncoded in "accessTokenModelToAccessTokenEntity"

`
public func getAccessToken(sub: String, callback: @escaping (Result) -> Void) {

    // getting current seconds
    let milliseconds = Date().timeIntervalSince1970
    let seconds = Int64(milliseconds)
    
    let accessTokenModel = DBHelper.shared.getAccessToken(key: sub)
    let expires = accessTokenModel.expires_in
    let secs: Int64 = Int64(accessTokenModel.seconds)
    let expires_in = expires + secs - 10
    
    if expires_in > seconds {
        
        if String(seconds).count < 10 {
            self.getAccessToken(refreshToken: accessTokenModel.refresh_token, callback: callback)
            return
        }
        
        EntityToModelConverter.shared.accessTokenModelToAccessTokenEntity(accessTokenModel: accessTokenModel) { (accessTokenEntity) in
            // return success callback
            let response = LoginResponseEntity()
            response.success = true
            response.status = 200
            response.data = accessTokenEntity
            
            DispatchQueue.main.async {
                callback(Result.success(result: response))
            }
            return
        }
    }
        
    else {
        self.getAccessToken(refreshToken: accessTokenModel.refresh_token, callback: callback)
    }
}

`

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

1 participant