mirror of
https://github.com/crivion/laranode.git
synced 2026-09-03 06:24:09 +08:00
ssl manager: stop asking for user email, use the one on the record
This commit is contained in:
@@ -90,14 +90,13 @@ class WebsiteController extends Controller
|
||||
Gate::authorize('update', $website);
|
||||
|
||||
$request->validate([
|
||||
'enabled' => 'required|boolean',
|
||||
'email' => 'required_if:enabled,true|email'
|
||||
'enabled' => 'required|boolean'
|
||||
]);
|
||||
|
||||
try {
|
||||
if ($request->enabled) {
|
||||
// Generate SSL certificate
|
||||
$this->generateSslCertificate($website, $request->email);
|
||||
$this->generateSslCertificate($website, $request->user()->email);
|
||||
} else {
|
||||
// Remove SSL certificate
|
||||
$this->removeSslCertificate($website);
|
||||
|
||||
@@ -60,6 +60,15 @@ check_domain_accessibility() {
|
||||
generate_ssl_certificate() {
|
||||
local domain=$1
|
||||
local email=$2
|
||||
local document_root=$3
|
||||
local webroot_path
|
||||
|
||||
# Prefer provided document root; fallback to default WEBROOT_PATH
|
||||
if [ -n "$document_root" ]; then
|
||||
webroot_path="$document_root"
|
||||
else
|
||||
webroot_path="$WEBROOT_PATH"
|
||||
fi
|
||||
|
||||
print_status "Generating SSL certificate for $domain..."
|
||||
|
||||
@@ -72,7 +81,7 @@ generate_ssl_certificate() {
|
||||
# Generate certificate using certbot
|
||||
if certbot certonly \
|
||||
--webroot \
|
||||
--webroot-path="$WEBROOT_PATH" \
|
||||
--webroot-path="$webroot_path" \
|
||||
--email "$email" \
|
||||
--agree-tos \
|
||||
--no-eff-email \
|
||||
@@ -207,18 +216,19 @@ renew_ssl_certificates() {
|
||||
# Main script logic
|
||||
case "$1" in
|
||||
"generate")
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 generate <domain> <email>"
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage: $0 generate <domain> <email> [document_root]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
domain=$2
|
||||
email=$3
|
||||
document_root=$4
|
||||
|
||||
check_certbot
|
||||
check_domain_accessibility "$domain"
|
||||
generate_ssl_certificate "$domain" "$email"
|
||||
create_ssl_vhost "$domain" "$4"
|
||||
generate_ssl_certificate "$domain" "$email" "$document_root"
|
||||
create_ssl_vhost "$domain" "$document_root"
|
||||
;;
|
||||
|
||||
"remove")
|
||||
|
||||
@@ -43,22 +43,8 @@ export default function Websites({ websites, serverIp }) {
|
||||
const isEnabled = website.ssl_enabled;
|
||||
const action = isEnabled ? 'disable' : 'enable';
|
||||
|
||||
if (!isEnabled) {
|
||||
// If enabling SSL, prompt for email
|
||||
const email = prompt('Please enter your email address for SSL certificate generation:');
|
||||
if (!email) return;
|
||||
|
||||
// Basic email validation
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(email)) {
|
||||
toast.error('Please enter a valid email address');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const requestData = {
|
||||
enabled: !isEnabled,
|
||||
...(isEnabled ? {} : { email: email })
|
||||
};
|
||||
|
||||
fetch(route('websites.ssl.toggle', { website: website.id }), {
|
||||
|
||||
Reference in New Issue
Block a user