mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-12-21 11:10:08 +01:00
✨ Re-secure domains via alert
This commit is contained in:
@@ -30,4 +30,6 @@ protocol ValetListable {
|
||||
|
||||
func getListableFavorited() -> Bool
|
||||
|
||||
func toggleSecure() async throws
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ extension DomainListVC {
|
||||
return false
|
||||
}
|
||||
|
||||
// If no expired domains exist, skip this alert
|
||||
if expired.isEmpty {
|
||||
return
|
||||
}
|
||||
|
||||
// An easily accessible list of domains
|
||||
let domainListing = "- " + expired.map {
|
||||
$0.getListableName() + "." + $0.getListableTLD()
|
||||
@@ -38,7 +43,7 @@ extension DomainListVC {
|
||||
description: "cert_alert.domains".localized(domainListing)
|
||||
)
|
||||
.withPrimary(text: "cert_alert.renew".localized, action: { vc in
|
||||
// TODO: renewal
|
||||
Task { await self.renewCertificates(expired) }
|
||||
vc.close(with: .OK)
|
||||
})
|
||||
.withSecondary(text: "cert_alert.cancel".localized, action: { vc in
|
||||
@@ -47,4 +52,23 @@ extension DomainListVC {
|
||||
.presentAsSheet(attachedTo: window)
|
||||
}
|
||||
}
|
||||
|
||||
public func renewCertificates(_ expired: [ValetListable]) async {
|
||||
waitAndExecute {
|
||||
for domain in expired {
|
||||
// Unsecure domain first
|
||||
try? await domain.toggleSecure()
|
||||
|
||||
// Resecure if unsecured
|
||||
if !domain.getListableSecured() {
|
||||
try? await domain.toggleSecure()
|
||||
}
|
||||
}
|
||||
} completion: {
|
||||
Task {
|
||||
await delay(seconds: 1)
|
||||
await self.reloadDomainsWithoutUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import Carbon
|
||||
import SwiftUI
|
||||
import NVAlert
|
||||
|
||||
// swiftlint:disable type_body_length file_length
|
||||
class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
var container: Container {
|
||||
return App.shared.container
|
||||
@@ -370,4 +369,3 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource
|
||||
Log.perf("deinit: \(String(describing: self)).\(#function)")
|
||||
}
|
||||
}
|
||||
// swiftlint:enable type_body_length file_length
|
||||
|
||||
@@ -924,6 +924,8 @@ If you want to make edits to this file, please do so before upgrading. When you
|
||||
"cert_alert.description" = "Certificates used to secure domains are usually valid for one year. Do you want PHP Monitor to unsecure and re-secure any expired domains?";
|
||||
"cert_alert.domains" = "The following certificates are affected and will be renewed:
|
||||
|
||||
%@";
|
||||
"cert_alert.renew" = "Renew Certificate(s)";
|
||||
"cert_alert.cancel" = "Cancel";
|
||||
%@
|
||||
|
||||
PHP Monitor will tell Valet to unsecure and re-secure all expired domains for you. This can take a while, as nginx may be restarted a few times if multiple domains need to be re-secured. You will be prompted about this issue every time this window opens, so it is recommended to take action now.";
|
||||
"cert_alert.renew" = "Re-secure Domain(s)";
|
||||
"cert_alert.cancel" = "Not Now";
|
||||
|
||||
Reference in New Issue
Block a user