|
@@ -232,7 +232,7 @@ func updateTgbotSetting(tgBotToken string, tgBotChatid string, tgBotRuntime stri
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func updateSetting(port int, username string, password string, webBasePath string, listenIP string) {
|
|
|
|
|
|
+func updateSetting(port int, username string, password string, webBasePath string, listenIP string, resetTwoFactor bool) {
|
|
err := database.InitDB(config.GetDBPath())
|
|
err := database.InitDB(config.GetDBPath())
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("Database initialization failed:", err)
|
|
fmt.Println("Database initialization failed:", err)
|
|
@@ -269,6 +269,17 @@ func updateSetting(port int, username string, password string, webBasePath strin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if resetTwoFactor {
|
|
|
|
+ err := settingService.SetTwoFactorEnable(false)
|
|
|
|
+
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("Failed to reset two-factor authentication:", err)
|
|
|
|
+ } else {
|
|
|
|
+ settingService.SetTwoFactorToken("")
|
|
|
|
+ fmt.Println("Two-factor authentication reset successfully")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if listenIP != "" {
|
|
if listenIP != "" {
|
|
err := settingService.SetListen(listenIP)
|
|
err := settingService.SetListen(listenIP)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -376,6 +387,7 @@ func main() {
|
|
var reset bool
|
|
var reset bool
|
|
var show bool
|
|
var show bool
|
|
var getCert bool
|
|
var getCert bool
|
|
|
|
+ var resetTwoFactor bool
|
|
settingCmd.BoolVar(&reset, "reset", false, "Reset all settings")
|
|
settingCmd.BoolVar(&reset, "reset", false, "Reset all settings")
|
|
settingCmd.BoolVar(&show, "show", false, "Display current settings")
|
|
settingCmd.BoolVar(&show, "show", false, "Display current settings")
|
|
settingCmd.IntVar(&port, "port", 0, "Set panel port number")
|
|
settingCmd.IntVar(&port, "port", 0, "Set panel port number")
|
|
@@ -383,6 +395,7 @@ func main() {
|
|
settingCmd.StringVar(&password, "password", "", "Set login password")
|
|
settingCmd.StringVar(&password, "password", "", "Set login password")
|
|
settingCmd.StringVar(&webBasePath, "webBasePath", "", "Set base path for Panel")
|
|
settingCmd.StringVar(&webBasePath, "webBasePath", "", "Set base path for Panel")
|
|
settingCmd.StringVar(&listenIP, "listenIP", "", "set panel listenIP IP")
|
|
settingCmd.StringVar(&listenIP, "listenIP", "", "set panel listenIP IP")
|
|
|
|
+ settingCmd.BoolVar(&resetTwoFactor, "resetTwoFactor", false, "Reset two-factor authentication settings")
|
|
settingCmd.BoolVar(&getListen, "getListen", false, "Display current panel listenIP IP")
|
|
settingCmd.BoolVar(&getListen, "getListen", false, "Display current panel listenIP IP")
|
|
settingCmd.BoolVar(&getCert, "getCert", false, "Display current certificate settings")
|
|
settingCmd.BoolVar(&getCert, "getCert", false, "Display current certificate settings")
|
|
settingCmd.StringVar(&webCertFile, "webCert", "", "Set path to public key file for panel")
|
|
settingCmd.StringVar(&webCertFile, "webCert", "", "Set path to public key file for panel")
|
|
@@ -427,7 +440,7 @@ func main() {
|
|
if reset {
|
|
if reset {
|
|
resetSetting()
|
|
resetSetting()
|
|
} else {
|
|
} else {
|
|
- updateSetting(port, username, password, webBasePath, listenIP)
|
|
|
|
|
|
+ updateSetting(port, username, password, webBasePath, listenIP, resetTwoFactor)
|
|
}
|
|
}
|
|
if show {
|
|
if show {
|
|
showSetting(show)
|
|
showSetting(show)
|