fix(system): fix issue with change system ssl failed (#8247)

This commit is contained in:
zhengkunwang 2025-03-25 19:11:02 +08:00 committed by GitHub
parent b3cd10b743
commit f13d496b35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 4 deletions

View file

@ -265,6 +265,7 @@ sqlInject: 'SQL 注入'
ErrDBNotExist: "数据库不存在" ErrDBNotExist: "数据库不存在"
allow: "允许" allow: "允许"
deny: "禁止" deny: "禁止"
OpenrestyNotFound: "Openresty 未安装"
#task #task
TaskStart: "{{.name}} 任务开始 [START]" TaskStart: "{{.name}} 任务开始 [START]"

View file

@ -2,7 +2,6 @@ package v2
import ( import (
"encoding/base64" "encoding/base64"
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper" "github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
"github.com/1Panel-dev/1Panel/core/app/dto" "github.com/1Panel-dev/1Panel/core/app/dto"
"github.com/1Panel-dev/1Panel/core/app/model" "github.com/1Panel-dev/1Panel/core/app/model"

View file

@ -232,6 +232,7 @@ func (u *SettingService) UpdatePort(port uint) error {
func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error { func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error {
secretDir := path.Join(global.CONF.Base.InstallDir, "1panel/secret") secretDir := path.Join(global.CONF.Base.InstallDir, "1panel/secret")
if req.SSL == constant.StatusDisable { if req.SSL == constant.StatusDisable {
c.SetCookie(constant.SessionName, "", -1, "/", "", false, true)
if err := settingRepo.Update("SSL", constant.StatusDisable); err != nil { if err := settingRepo.Update("SSL", constant.StatusDisable); err != nil {
return err return err
} }

View file

@ -2,9 +2,11 @@ package common
import ( import (
"fmt" "fmt"
"github.com/1Panel-dev/1Panel/core/constant"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
mathRand "math/rand" mathRand "math/rand"
"net" "net"
"net/http"
"os" "os"
"path" "path"
"strconv" "strconv"
@ -205,3 +207,14 @@ func HandleIPList(content string) ([]string, error) {
} }
return res, nil return res, nil
} }
func deleteCookie(w http.ResponseWriter) {
cookie := &http.Cookie{
Name: constant.SessionName,
Value: "",
Path: "/",
Expires: time.Unix(0, 0),
MaxAge: -1,
}
http.SetCookie(w, cookie)
}

View file

@ -89,7 +89,7 @@ const systemRules: TokenRule[] = [
const taskRules: TokenRule[] = [ const taskRules: TokenRule[] = [
{ {
type: 'bracket-text', type: 'bracket-text',
pattern: /\[([^\,]]+)\]/g, pattern: /\[([^\]]+)\]/g,
color: '#B87A2B', color: '#B87A2B',
}, },
]; ];
@ -108,7 +108,7 @@ const defaultRules: TokenRule[] = [
}, },
{ {
type: 'ip', type: 'ip',
pattern: /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, pattern: /\b(?<!\[)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b(?!\])/g,
color: '#4A90E2', color: '#4A90E2',
}, },
{ {

View file

@ -245,7 +245,7 @@ const onSaveSSL = async (formEl: FormInstance | undefined) => {
if (globalStore.entrance) { if (globalStore.entrance) {
address = address.replaceAll('settings/safe', globalStore.entrance); address = address.replaceAll('settings/safe', globalStore.entrance);
} else { } else {
address = address.replaceAll('settings/safe', 'login'); address = address.replaceAll('settings/safe', '');
} }
setTimeout(() => { setTimeout(() => {
window.open(`https://${address}`, '_self'); window.open(`https://${address}`, '_self');