Skip to content

Commit

Permalink
[iOS] - Fix authentication popup showing the realm (#27114)
Browse files Browse the repository at this point in the history
* Remove realm from basic-auth alert. Add full origin to the alert.
  • Loading branch information
Brandon-T authored Jan 3, 2025
1 parent 2a3f555 commit cf007ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
35 changes: 15 additions & 20 deletions ios/brave-ios/Sources/Brave/Frontend/Browser/Authenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions ios/brave-ios/Sources/BraveStrings/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit cf007ac

Please sign in to comment.