Skip to content

Commit

Permalink
Fix: Error handling in redirect URL
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan committed Sep 2, 2024
1 parent 1f3245f commit a8d2727
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/eudiWalletOidcIos/Service/VerificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,13 @@ public class VerificationService: NSObject, VerificationServiceProtocol {
if httpres?.statusCode == 302 || httpres?.statusCode == 200 {
if let location = httpres?.value(forHTTPHeaderField: "Location") {
responseUrl = location
return WrappedVerificationResponse(data: responseUrl, error: nil)
let url = URL.init(string: location)
if let errorDescription = url?.queryParameters?["error_description"] as? String {
let error = errorDescription.replacingOccurrences(of: "+", with: " ").data(using: .utf8)
return WrappedVerificationResponse(data: nil, error: ErrorHandler.processError(data: error))
} else {
return WrappedVerificationResponse(data: responseUrl, error: nil)
}
} else {
return WrappedVerificationResponse(data: "https://www.example.com?code=1", error: nil)
}
Expand Down

0 comments on commit a8d2727

Please sign in to comment.