Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 7f01628

Browse files
Merge pull request #121 from wordpress-mobile/feature/invalid-token
Feature/invalid token
2 parents 1260d2c + debd56f commit 7f01628

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

WordPressKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressKit"
3-
s.version = "3.0.0"
3+
s.version = "3.1.0"
44
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."
55

66
s.description = <<-DESC

WordPressKit/WordPressComRestApi.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ open class WordPressComRestApi: NSObject {
6060

6161
private let localeKey: String
6262

63+
private var invalidTokenHandler: (() -> Void)? = nil
64+
6365
/**
6466
Configure whether or not the user's preferred language locale should be appended. Defaults to true.
6567
*/
@@ -154,6 +156,10 @@ open class WordPressComRestApi: NSObject {
154156
uploadSessionManager.session.invalidateAndCancel()
155157
}
156158

159+
@objc func setInvalidTokenHandler(_ handler: @escaping () -> Void) {
160+
invalidTokenHandler = handler
161+
}
162+
157163
// MARK: Network requests
158164

159165
private func request(method: HTTPMethod,
@@ -443,6 +449,9 @@ extension WordPressComRestApi {
443449
]
444450

445451
let mappedError = errorsMap[errorCode] ?? WordPressComRestApiError.unknown
452+
if mappedError == .invalidToken {
453+
invalidTokenHandler?()
454+
}
446455
userInfo[WordPressComRestApi.ErrorKeyErrorCode] = errorCode
447456
userInfo[WordPressComRestApi.ErrorKeyErrorMessage] = errorDescription
448457
userInfo[NSLocalizedDescriptionKey] = errorDescription

0 commit comments

Comments
 (0)