diff --git a/Cidaas.podspec b/Cidaas.podspec index 01553f0..ed9b8e1 100644 --- a/Cidaas.podspec +++ b/Cidaas.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'Cidaas' - s.version = '1.1.0.2' + s.version = '1.1.1' s.summary = 'Native SDK for iOS providing login, registration and verification functionalities' s.homepage = 'https://github.com/Cidaas/cidaas-sdk-ios-v2' s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/Cidaas/Classes/Core/Controllers/Repository/AccessToken/AccessTokenController.swift b/Cidaas/Classes/Core/Controllers/Repository/AccessToken/AccessTokenController.swift index 8349c51..d105790 100644 --- a/Cidaas/Classes/Core/Controllers/Repository/AccessToken/AccessTokenController.swift +++ b/Cidaas/Classes/Core/Controllers/Repository/AccessToken/AccessTokenController.swift @@ -78,6 +78,12 @@ public class AccessTokenController { 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() @@ -93,43 +99,7 @@ public class AccessTokenController { } else { - let properties = DBHelper.shared.getPropertyFile() - if (properties == nil) { - // return failure callback - DispatchQueue.main.async { - callback(Result.failure(error: WebAuthError.shared.propertyMissingException())) - } - return - } - - // call access token from refresh token service - AccessTokenService.shared.getAccessToken(refreshToken: accessTokenModel.refresh_token, properties: properties!) { - switch $0 { - case .failure(let error): - - // log error - let loggerMessage = "Access token from refresh token service failure : " + "Error Code - " + String(describing: error.errorCode) + ", Error Message - " + String(describing: error.error) + ", Status Code - " + String(describing: error.statusCode) - logw(loggerMessage, cname: "cidaas-sdk-error-log") - - // return failure callback - DispatchQueue.main.async { - callback(Result.failure(error: error)) - } - return - case .success(let accessTokenEntity): - - // log success - let loggerMessage = "Access token from refresh token service success : " + "Access Token - " + accessTokenEntity.access_token + ", Refresh Token - " + accessTokenEntity.refresh_token + ", Expires In Time - " + String(describing: accessTokenEntity.expires_in) - logw(loggerMessage, cname: "cidaas-sdk-success-log") - - // assign to access token model - EntityToModelConverter.shared.accessTokenEntityToAccessTokenModel(accessTokenEntity: accessTokenEntity, callback: { _ in - - self.saveAccessToken(accessTokenEntity: accessTokenEntity, callback: callback) - - }) - } - } + self.getAccessToken(refreshToken: accessTokenModel.refresh_token, callback: callback) } }