Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily allow fallback to internal URL #3265

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ class ConnectionSettingsViewController: HAFormViewController, RowControllerType
row.cellStyle = .value1
row.title = L10n.Settings.ConnectionSection.InternalBaseUrl.title
row.displayValueFor = { [server] _ in
if server.info.connection.internalSSIDs?.isEmpty ?? true,
server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
!server.info.connection.alwaysFallbackToInternalURL {
return "‼️ \(L10n.Settings.ConnectionSection.InternalBaseUrl.RequiresSetup.title)"
} else {
return server.info.connection.address(for: .internal)?.absoluteString ?? "—"
}
// if server.info.connection.internalSSIDs?.isEmpty ?? true,
// server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
// !server.info.connection.alwaysFallbackToInternalURL {
// return "‼️ \(L10n.Settings.ConnectionSection.InternalBaseUrl.RequiresSetup.title)"
// } else {
server.info.connection.address(for: .internal)?.absoluteString ?? "—"
// }
}
row.presentationMode = .show(controllerProvider: .callback(builder: { [server] in
ConnectionURLViewController(server: server, urlType: .internal, row: row)
Expand Down
88 changes: 44 additions & 44 deletions Sources/App/Settings/Connection/ConnectionURLViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,18 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle
}
<<< InfoLabelRow {
$0.tag = RowTag.internalURLWarning.rawValue
if server.info.connection.internalSSIDs?.isEmpty ?? true,
server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
!server.info.connection.alwaysFallbackToInternalURL {
#if targetEnvironment(macCatalyst)
$0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidBssidRequired.title
#else
$0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidRequired.title

#endif
} else {
$0.title = L10n.Settings.ConnectionSection.InternalBaseUrl.SsidRequired.title
}
// if server.info.connection.internalSSIDs?.isEmpty ?? true,
// server.info.connection.internalHardwareAddresses?.isEmpty ?? true,
// !server.info.connection.alwaysFallbackToInternalURL {
// #if targetEnvironment(macCatalyst)
// $0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidBssidRequired.title
// #else
// $0.title = "‼️" + L10n.Settings.ConnectionSection.InternalBaseUrl.SsidRequired.title
//
// #endif
// } else {
$0.title = L10n.Settings.ConnectionSection.InternalBaseUrl.SsidRequired.title
// }
}

if urlType.isAffectedBySSID {
Expand Down Expand Up @@ -296,38 +296,38 @@ final class ConnectionURLViewController: HAFormViewController, TypedRowControlle
}
}

form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer)
<<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) {
$0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title
$0.value = server.info.connection.alwaysFallbackToInternalURL

$0.cellUpdate { cell, _ in
cell.switchControl.onTintColor = .red
}

$0.onChange { [weak self] row in
if row.value ?? false {
let alert = UIAlertController(
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title,
message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message,
preferredStyle: .actionSheet
)
alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in
self?.server.info.connection.alwaysFallbackToInternalURL = false
row.value = false
row.cellUpdate { _, row in
row.value = false
}
row.reload()
}))
alert.addAction(UIAlertAction(
title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.confirmButton,
style: .destructive
))
self?.present(alert, animated: true)
}
}
}
// form +++ Section(footer: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.footer)
// <<< SwitchRow(RowTag.alwaysFallbackToInternalURL.rawValue) {
// $0.title = L10n.Settings.ConnectionSection.AlwaysFallbackInternal.title
// $0.value = server.info.connection.alwaysFallbackToInternalURL
//
// $0.cellUpdate { cell, _ in
// cell.switchControl.onTintColor = .red
// }
//
// $0.onChange { [weak self] row in
// if row.value ?? false {
// let alert = UIAlertController(
// title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.title,
// message: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.message,
// preferredStyle: .actionSheet
// )
// alert.addAction(UIAlertAction(title: L10n.cancelLabel, style: .cancel, handler: { _ in
// self?.server.info.connection.alwaysFallbackToInternalURL = false
// row.value = false
// row.cellUpdate { _, row in
// row.value = false
// }
// row.reload()
// }))
// alert.addAction(UIAlertAction(
// title: L10n.Settings.ConnectionSection.AlwaysFallbackInternal.Confirmation.confirmButton,
// style: .destructive
// ))
// self?.present(alert, animated: true)
// }
// }
// }
}

private func locationPermissionSection() -> Section {
Expand Down
10 changes: 8 additions & 2 deletions Sources/Shared/API/ConnectionInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,14 @@ public struct ConnectionInfo: Codable, Equatable {
activeURLType = .internal
url = internalURL
} else {
activeURLType = .none
url = nil
// activeURLType = .none
// url = nil

// Temporarily allow fallback to internal URL if no URL is available
// TODO: Remove this fallback as soonas a better communication is available for this security change.
activeURLType = .internal
url = internalURL

/*
No URL that can be used in this context is available
This can happen when only internal URL is set and
Expand Down
Loading