fix(admin): Admin web title

This commit is contained in:
lejianwen
2025-02-12 21:10:07 +08:00
parent 6aebf061a4
commit 63cf231bdc
4 changed files with 16 additions and 4 deletions

View File

@@ -1 +1 @@
### 👏👏👏 你好 ***{{username}}*** 欢迎使用 [RustDesk Api](https://github.com/lejianwen/rustdesk-api)
### 👏👏👏 你好 ***{{username}}*** 欢迎使用 [RustDesk API](https://github.com/lejianwen/rustdesk-api)

View File

@@ -61,6 +61,12 @@ func (co *Config) AppConfig(c *gin.Context) {
func (co *Config) AdminConfig(c *gin.Context) {
u := service.AllService.UserService.CurUser(c)
if u == nil || u.Id == 0 {
response.Success(c, &gin.H{
"title": global.Config.Admin.Title,
})
return
}
hello := global.Config.Admin.Hello
helloFile := global.Config.Admin.HelloFile
if helloFile != "" {

View File

@@ -22,6 +22,9 @@ func Init(g *gin.Engine) {
adg := g.Group("/api/admin")
LoginBind(adg)
adg.POST("/user/register", (&admin.User{}).Register)
ConfigBind(adg)
adg.Use(middleware.AdminAuth())
//FileBind(adg)
UserBind(adg)
@@ -35,7 +38,6 @@ func Init(g *gin.Engine) {
AddressBookCollectionBind(adg)
AddressBookCollectionRuleBind(adg)
UserTokenBind(adg)
ConfigBind(adg)
//deprecated by ConfigBind
//rs := &admin.Rustdesk{}
@@ -221,9 +223,13 @@ func UserTokenBind(rg *gin.RouterGroup) {
func ConfigBind(rg *gin.RouterGroup) {
aR := rg.Group("/config")
rs := &admin.Config{}
aR.GET("/admin", rs.AdminConfig)
aR.Use(middleware.AdminAuth())
aR.GET("/server", rs.ServerConfig)
aR.GET("/app", rs.AppConfig)
aR.GET("/admin", rs.AdminConfig)
}
/*

View File

@@ -280,7 +280,7 @@ func (us *UserService) UpdatePassword(u *model.User, password string) error {
// IsAdmin 是否管理员
func (us *UserService) IsAdmin(u *model.User) bool {
return *u.IsAdmin
return u != nil && *u.IsAdmin
}
// RouteNames