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

Commit 7db2845

Browse files
committed
Check for invalid WP site
1 parent 01c8c7d commit 7db2845

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

WordPressAuthenticator/Services/WordPressComBlogService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class WordPressComBlogService {
4242
}
4343

4444
let site = WordPressComSiteInfo(remote: response)
45+
guard site.url != Constants.wordPressBlogURL else {
46+
failure(WordPressOrgXMLRPCValidatorError.invalid)
47+
return
48+
}
4549
success(site)
4650
}, failure: { error in
4751
let result = error ?? ServiceError.unknown
@@ -53,6 +57,9 @@ class WordPressComBlogService {
5357
// MARK: - Nested Types
5458
//
5559
extension WordPressComBlogService {
60+
enum Constants {
61+
static let wordPressBlogURL = "https://wordpress.com/blog"
62+
}
5663

5764
enum ServiceError: Error {
5865
case unknown

WordPressAuthenticator/Unified Auth/View Related/Site Address/SiteAddressViewController.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,19 @@ private extension SiteAddressViewController {
541541
self.presentNextControllerIfPossible(siteInfo: siteInfo)
542542
}
543543

544-
service.fetchUnauthenticatedSiteInfoForAddress(for: baseSiteUrl, success: successBlock, failure: { [weak self] _ in
544+
service.fetchUnauthenticatedSiteInfoForAddress(for: baseSiteUrl, success: successBlock, failure: { [weak self] error in
545545
self?.configureViewLoading(false)
546546
guard let self = self else {
547547
return
548548
}
549-
self.presentNextControllerIfPossible(siteInfo: nil)
549+
550+
if self.authenticationDelegate.shouldHandleError(error) {
551+
self.authenticationDelegate.handleError(error) { [weak self] customUI in
552+
self?.navigationController?.pushViewController(customUI, animated: true)
553+
}
554+
} else {
555+
self.displayError(error, sourceTag: self.sourceTag)
556+
}
550557
})
551558
}
552559

0 commit comments

Comments
 (0)