mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
refactor: migrate to new cosy
This commit is contained in:
parent
6082aef5d5
commit
33a996e777
111 changed files with 1163 additions and 1772 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/0xJacky/Nginx-UI/internal/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/load"
|
||||
|
|
|
@ -3,7 +3,7 @@ package analytic
|
|||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"net/http"
|
||||
|
|
|
@ -2,7 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
|
|
@ -2,12 +2,12 @@ package certificate
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -31,7 +31,7 @@ func CreateAcmeUser(c *gin.Context) {
|
|||
"register_on_startup": "omitempty",
|
||||
}).BeforeExecuteHook(func(ctx *cosy.Ctx[model.AcmeUser]) {
|
||||
if ctx.Model.CADir == "" {
|
||||
ctx.Model.CADir = settings.ServerSettings.GetCADir()
|
||||
ctx.Model.CADir = settings.CertSettings.GetCADir()
|
||||
}
|
||||
err := ctx.Model.Register()
|
||||
if err != nil {
|
||||
|
@ -50,7 +50,7 @@ func ModifyAcmeUser(c *gin.Context) {
|
|||
"register_on_startup": "omitempty",
|
||||
}).BeforeExecuteHook(func(ctx *cosy.Ctx[model.AcmeUser]) {
|
||||
if ctx.Model.CADir == "" {
|
||||
ctx.Model.CADir = settings.ServerSettings.GetCADir()
|
||||
ctx.Model.CADir = settings.CertSettings.GetCADir()
|
||||
}
|
||||
|
||||
if ctx.OriginModel.Email != ctx.Model.Email ||
|
||||
|
|
|
@ -3,7 +3,6 @@ package certificate
|
|||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cert"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
|
|
@ -3,11 +3,11 @@ package certificate
|
|||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cert/dns"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package certificate
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/cert"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/analytic"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cluster"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
)
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func GetCurrentNode(c *gin.Context) {
|
||||
if _, ok := c.Get("NodeSecret"); !ok {
|
||||
if _, ok := c.Get("Secret"); !ok {
|
||||
c.JSON(http.StatusNotAcceptable, gin.H{
|
||||
"message": "node secret not exist",
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@ package config
|
|||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/config"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/config"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cache"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
|
@ -2,11 +2,11 @@ package notification
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,12 +6,13 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
cSettings "github.com/uozi-tech/cosy/settings"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetServerName(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"name": settings.ServerSettings.Name,
|
||||
"name": settings.NodeSettings.Name,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -19,7 +20,7 @@ func GetSettings(c *gin.Context) {
|
|||
settings.NginxSettings.AccessLogPath = nginx.GetAccessLogPath()
|
||||
settings.NginxSettings.ErrorLogPath = nginx.GetErrorLogPath()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"server": settings.ServerSettings,
|
||||
"server": cSettings.ServerSettings,
|
||||
"nginx": settings.NginxSettings,
|
||||
"openai": settings.OpenAISettings,
|
||||
"logrotate": settings.LogrotateSettings,
|
||||
|
@ -29,7 +30,7 @@ func GetSettings(c *gin.Context) {
|
|||
|
||||
func SaveSettings(c *gin.Context) {
|
||||
var json struct {
|
||||
Server settings.Server `json:"server"`
|
||||
Server cSettings.Server `json:"server"`
|
||||
Nginx settings.Nginx `json:"nginx"`
|
||||
Openai settings.OpenAI `json:"openai"`
|
||||
Logrotate settings.Logrotate `json:"logrotate"`
|
||||
|
@ -45,11 +46,11 @@ func SaveSettings(c *gin.Context) {
|
|||
go cron.RestartLogrotate()
|
||||
}
|
||||
|
||||
settings.ProtectedFill(&settings.ServerSettings, &json.Server)
|
||||
settings.ProtectedFill(&settings.NginxSettings, &json.Nginx)
|
||||
settings.ProtectedFill(&settings.OpenAISettings, &json.Openai)
|
||||
settings.ProtectedFill(&settings.LogrotateSettings, &json.Logrotate)
|
||||
settings.ProtectedFill(&settings.AuthSettings, &json.Auth)
|
||||
cSettings.ProtectedFill(cSettings.ServerSettings, &json.Server)
|
||||
cSettings.ProtectedFill(settings.NginxSettings, &json.Nginx)
|
||||
cSettings.ProtectedFill(settings.OpenAISettings, &json.Openai)
|
||||
cSettings.ProtectedFill(settings.LogrotateSettings, &json.Logrotate)
|
||||
cSettings.ProtectedFill(settings.AuthSettings, &json.Auth)
|
||||
|
||||
err := settings.Save()
|
||||
if err != nil {
|
||||
|
|
41
api/sites/category.go
Normal file
41
api/sites/category.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package sites
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/uozi-tech/cosy"
|
||||
)
|
||||
|
||||
func GetCategory(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func GetCategoryList(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).PagingList()
|
||||
}
|
||||
|
||||
func AddCategory(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).
|
||||
SetValidRules(gin.H{
|
||||
"name": "required",
|
||||
"sync_node_ids": "omitempty",
|
||||
}).
|
||||
Create()
|
||||
}
|
||||
|
||||
func ModifyCategory(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).
|
||||
SetValidRules(gin.H{
|
||||
"name": "required",
|
||||
"sync_node_ids": "omitempty",
|
||||
}).
|
||||
Modify()
|
||||
}
|
||||
|
||||
func DeleteCategory(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).Destroy()
|
||||
}
|
||||
|
||||
func RecoverCategory(c *gin.Context) {
|
||||
cosy.Core[model.SiteCategory](c).Recover()
|
||||
}
|
|
@ -3,9 +3,8 @@ package sites
|
|||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cert"
|
||||
"github.com/0xJacky/Nginx-UI/internal/config"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
|
@ -13,68 +12,8 @@ import (
|
|||
"github.com/sashabaranov/go-openai"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetSiteList(c *gin.Context) {
|
||||
name := c.Query("name")
|
||||
enabled := c.Query("enabled")
|
||||
orderBy := c.Query("order_by")
|
||||
sort := c.DefaultQuery("sort", "desc")
|
||||
|
||||
configFiles, err := os.ReadDir(nginx.GetConfPath("sites-available"))
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
enabledConfig, err := os.ReadDir(nginx.GetConfPath("sites-enabled"))
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
enabledConfigMap := make(map[string]bool)
|
||||
for i := range enabledConfig {
|
||||
enabledConfigMap[enabledConfig[i].Name()] = true
|
||||
}
|
||||
|
||||
var configs []config.Config
|
||||
|
||||
for i := range configFiles {
|
||||
file := configFiles[i]
|
||||
fileInfo, _ := file.Info()
|
||||
if !file.IsDir() {
|
||||
// name filter
|
||||
if name != "" && !strings.Contains(file.Name(), name) {
|
||||
continue
|
||||
}
|
||||
// status filter
|
||||
if enabled != "" {
|
||||
if enabled == "true" && !enabledConfigMap[file.Name()] {
|
||||
continue
|
||||
}
|
||||
if enabled == "false" && enabledConfigMap[file.Name()] {
|
||||
continue
|
||||
}
|
||||
}
|
||||
configs = append(configs, config.Config{
|
||||
Name: file.Name(),
|
||||
ModifiedAt: fileInfo.ModTime(),
|
||||
Size: fileInfo.Size(),
|
||||
IsDir: fileInfo.IsDir(),
|
||||
Enabled: enabledConfigMap[file.Name()],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
configs = config.Sort(orderBy, sort, configs)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": configs,
|
||||
})
|
||||
}
|
||||
|
||||
func GetSite(c *gin.Context) {
|
||||
rewriteName, ok := c.Get("rewriteConfigFileName")
|
||||
name := c.Param("name")
|
||||
|
|
70
api/sites/list.go
Normal file
70
api/sites/list.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
package sites
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/config"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetSiteList(c *gin.Context) {
|
||||
name := c.Query("name")
|
||||
enabled := c.Query("enabled")
|
||||
orderBy := c.Query("order_by")
|
||||
sort := c.DefaultQuery("sort", "desc")
|
||||
|
||||
configFiles, err := os.ReadDir(nginx.GetConfPath("sites-available"))
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
enabledConfig, err := os.ReadDir(nginx.GetConfPath("sites-enabled"))
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
enabledConfigMap := make(map[string]bool)
|
||||
for i := range enabledConfig {
|
||||
enabledConfigMap[enabledConfig[i].Name()] = true
|
||||
}
|
||||
|
||||
var configs []config.Config
|
||||
|
||||
for i := range configFiles {
|
||||
file := configFiles[i]
|
||||
fileInfo, _ := file.Info()
|
||||
if !file.IsDir() {
|
||||
// name filter
|
||||
if name != "" && !strings.Contains(file.Name(), name) {
|
||||
continue
|
||||
}
|
||||
// status filter
|
||||
if enabled != "" {
|
||||
if enabled == "true" && !enabledConfigMap[file.Name()] {
|
||||
continue
|
||||
}
|
||||
if enabled == "false" && enabledConfigMap[file.Name()] {
|
||||
continue
|
||||
}
|
||||
}
|
||||
configs = append(configs, config.Config{
|
||||
Name: file.Name(),
|
||||
ModifiedAt: fileInfo.ModTime(),
|
||||
Size: fileInfo.Size(),
|
||||
IsDir: fileInfo.IsDir(),
|
||||
Enabled: enabledConfigMap[file.Name()],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
configs = config.Sort(orderBy, sort, configs)
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": configs,
|
||||
})
|
||||
}
|
|
@ -14,3 +14,12 @@ func InitRouter(r *gin.RouterGroup) {
|
|||
r.POST("auto_cert/:name", AddDomainToAutoCert)
|
||||
r.DELETE("auto_cert/:name", RemoveDomainFromAutoCert)
|
||||
}
|
||||
|
||||
func InitCategoryRouter(r *gin.RouterGroup) {
|
||||
r.GET("site_categories", GetCategoryList)
|
||||
r.GET("site_category/:id", GetCategory)
|
||||
r.POST("site_category", AddCategory)
|
||||
r.PUT("site_category/:id", ModifyCategory)
|
||||
r.DELETE("site_category/:id", DeleteCategory)
|
||||
r.POST("site_category/:id/recover", RecoverCategory)
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
cSettings "github.com/uozi-tech/cosy/settings"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func installLockStatus() bool {
|
||||
return settings.ServerSettings.SkipInstallation || "" != settings.ServerSettings.JwtSecret
|
||||
return settings.NodeSettings.SkipInstallation || "" != cSettings.AppSettings.JwtSecret
|
||||
}
|
||||
|
||||
func InstallLockCheck(c *gin.Context) {
|
||||
|
@ -43,11 +44,11 @@ func InstallNginxUI(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
settings.ServerSettings.JwtSecret = uuid.New().String()
|
||||
settings.ServerSettings.NodeSecret = uuid.New().String()
|
||||
settings.ServerSettings.Email = json.Email
|
||||
cSettings.AppSettings.JwtSecret = uuid.New().String()
|
||||
settings.NodeSettings.Secret = uuid.New().String()
|
||||
settings.CertSettings.Email = json.Email
|
||||
if "" != json.Database {
|
||||
settings.ServerSettings.Database = json.Database
|
||||
cSettings.DataBaseSettings.Name = json.Database
|
||||
}
|
||||
|
||||
err := settings.Save()
|
||||
|
|
|
@ -2,11 +2,11 @@ package system
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/upgrader"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
@ -135,7 +135,7 @@ func PerformCoreUpgrade(c *gin.Context) {
|
|||
Message: "Performing core upgrade",
|
||||
})
|
||||
// dry run
|
||||
if control.DryRun || settings.ServerSettings.Demo {
|
||||
if control.DryRun || settings.NodeSettings.Demo {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package terminal
|
||||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/pty"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
|
|
|
@ -2,7 +2,7 @@ package upstream
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/upstream"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
|
|
|
@ -2,7 +2,7 @@ package user
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/user"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
func GenerateTOTP(c *gin.Context) {
|
||||
u := api.CurrentUser(c)
|
||||
|
||||
issuer := fmt.Sprintf("Nginx UI %s", settings.ServerSettings.Name)
|
||||
issuer := fmt.Sprintf("Nginx UI %s", settings.NodeSettings.Name)
|
||||
issuer = strings.TrimSpace(issuer)
|
||||
|
||||
otpOpts := totp.GenerateOpts{
|
||||
|
@ -70,7 +70,7 @@ func EnrollTOTP(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if settings.ServerSettings.Demo {
|
||||
if settings.NodeSettings.Demo {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"message": "This feature is disabled in demo mode",
|
||||
})
|
||||
|
|
|
@ -5,8 +5,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cache"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/0xJacky/Nginx-UI/internal/passkey"
|
||||
"github.com/0xJacky/Nginx-UI/internal/user"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
|
@ -15,6 +13,8 @@ import (
|
|||
"github.com/go-webauthn/webauthn/webauthn"
|
||||
"github.com/google/uuid"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
|
|
@ -2,12 +2,12 @@ package user
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/internal/cosy"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/uozi-tech/cosy"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ func AddUser(c *gin.Context) {
|
|||
func EditUser(c *gin.Context) {
|
||||
userId := cast.ToInt(c.Param("id"))
|
||||
|
||||
if settings.ServerSettings.Demo && userId == 1 {
|
||||
if settings.NodeSettings.Demo && userId == 1 {
|
||||
c.JSON(http.StatusNotAcceptable, gin.H{
|
||||
"message": "Changing user password is forbidden in demo mode",
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue