TF-2871 Fix validate expire time in swift code
This commit is contained in:
@@ -69,7 +69,7 @@ class AuthenticationInterceptor: RequestInterceptor {
|
||||
private func validateToRefreshToken(response: HTTPURLResponse, authenticationSSO: AuthenticationSSO) -> Bool {
|
||||
return response.statusCode == 401 &&
|
||||
!authenticationSSO.refreshToken.isEmpty &&
|
||||
authenticationSSO.isExpiredTime()
|
||||
authenticationSSO.isExpiredTime(currentDate: CoreUtils.shared.getCurrentDate())
|
||||
}
|
||||
|
||||
// MARK: - Handle refresh token to get new token
|
||||
|
||||
@@ -18,23 +18,15 @@ struct AuthenticationSSO: Authentication {
|
||||
return "Bearer \(accessToken)"
|
||||
}
|
||||
|
||||
func isExpiredTime() -> Bool {
|
||||
func isExpiredTime(currentDate: Date) -> Bool {
|
||||
guard let expireTime else {
|
||||
return false
|
||||
}
|
||||
|
||||
if #available(iOSApplicationExtension 15, *) {
|
||||
guard let expireDate = expireTime.convertISO8601StringToDate(),
|
||||
expireDate.isBefore(Date.now) else {
|
||||
return true
|
||||
}
|
||||
|
||||
if let expireDate = expireTime.convertISO8601StringToDate() {
|
||||
return expireDate.isBefore(currentDate)
|
||||
} else {
|
||||
guard let expireDate = expireTime.convertISO8601StringToDate(),
|
||||
expireDate.isBefore(Date()) else {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user