From cf007ac840418fff717b24ef297410c8abe9f516 Mon Sep 17 00:00:00 2001 From: Brandon-T Date: Fri, 3 Jan 2025 16:22:24 -0500 Subject: [PATCH] [iOS] - Fix authentication popup showing the realm (#27114) * Remove realm from basic-auth alert. Add full origin to the alert. --- .../Frontend/Browser/Authenticator.swift | 35 ++++++++----------- .../Sources/BraveStrings/BraveStrings.swift | 8 ----- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/Authenticator.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/Authenticator.swift index c34e9742cba6..ca313feaa2b5 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Authenticator.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Authenticator.swift @@ -82,28 +82,23 @@ class Authenticator { } return try await withCheckedThrowingContinuation { continuation in - let alert: AlertController + var origin = "" + if let scheme = protectionSpace.protocol { + if scheme == "http" || scheme == "https" { + origin += "\(scheme)://" + } else { + origin += "\(scheme):" + } + } - if !(protectionSpace.realm?.isEmpty ?? true) { - let formatted = String( - format: Strings.authPromptAlertFormatRealmMessageText, - protectionSpace.host, - protectionSpace.realm ?? "" - ) - alert = AlertController( - title: Strings.authPromptAlertTitle, - message: formatted, - preferredStyle: .alert - ) - } else { + origin += "\(protectionSpace.host):\(protectionSpace.port)" - let formatted = String(format: Strings.authPromptAlertMessageText, protectionSpace.host) - alert = AlertController( - title: Strings.authPromptAlertTitle, - message: formatted, - preferredStyle: .alert - ) - } + let formatted = String(format: Strings.authPromptAlertMessageText, origin) + let alert = AlertController( + title: Strings.authPromptAlertTitle, + message: formatted, + preferredStyle: .alert + ) // Add a button to log in. let action = UIAlertAction(title: Strings.authPromptAlertLogInButtonTitle, style: .default) { diff --git a/ios/brave-ios/Sources/BraveStrings/BraveStrings.swift b/ios/brave-ios/Sources/BraveStrings/BraveStrings.swift index 2a27cd39c880..ffe4b31c704f 100644 --- a/ios/brave-ios/Sources/BraveStrings/BraveStrings.swift +++ b/ios/brave-ios/Sources/BraveStrings/BraveStrings.swift @@ -425,14 +425,6 @@ extension Strings { value: "Authentication required", comment: "Authentication prompt title" ) - public static let authPromptAlertFormatRealmMessageText = NSLocalizedString( - "AuthPromptAlertFormatRealmMessageText", - tableName: "BraveShared", - bundle: .module, - value: "A username and password are being requested by %@. The site says: %@", - comment: - "Authentication prompt message with a realm. First parameter is the hostname. Second is the realm string" - ) public static let authPromptAlertMessageText = NSLocalizedString( "AuthPromptAlertMessageText", tableName: "BraveShared",