Browse Source

fix(admin): Admin hello

lejianwen 11 months ago
parent
commit
ee0cbabffc
1 changed files with 12 additions and 2 deletions
  1. 12 2
      http/controller/admin/config.go

+ 12 - 2
http/controller/admin/config.go

@@ -4,6 +4,7 @@ import (
4
 	"github.com/gin-gonic/gin"
4
 	"github.com/gin-gonic/gin"
5
 	"github.com/lejianwen/rustdesk-api/v2/global"
5
 	"github.com/lejianwen/rustdesk-api/v2/global"
6
 	"github.com/lejianwen/rustdesk-api/v2/http/response"
6
 	"github.com/lejianwen/rustdesk-api/v2/http/response"
7
+	"github.com/lejianwen/rustdesk-api/v2/model"
7
 	"github.com/lejianwen/rustdesk-api/v2/service"
8
 	"github.com/lejianwen/rustdesk-api/v2/service"
8
 	"os"
9
 	"os"
9
 	"strings"
10
 	"strings"
@@ -60,13 +61,22 @@ func (co *Config) AppConfig(c *gin.Context) {
60
 // @Security token
61
 // @Security token
61
 func (co *Config) AdminConfig(c *gin.Context) {
62
 func (co *Config) AdminConfig(c *gin.Context) {
62
 
63
 
63
-	u := service.AllService.UserService.CurUser(c)
64
-	if u == nil || u.Id == 0 {
64
+	u := &model.User{}
65
+	token := c.GetHeader("api-token")
66
+	if token != "" {
67
+		u, _ = service.AllService.UserService.InfoByAccessToken(token)
68
+		if !service.AllService.UserService.CheckUserEnable(u) {
69
+			u.Id = 0
70
+		}
71
+	}
72
+
73
+	if u.Id == 0 {
65
 		response.Success(c, &gin.H{
74
 		response.Success(c, &gin.H{
66
 			"title": global.Config.Admin.Title,
75
 			"title": global.Config.Admin.Title,
67
 		})
76
 		})
68
 		return
77
 		return
69
 	}
78
 	}
79
+
70
 	hello := global.Config.Admin.Hello
80
 	hello := global.Config.Admin.Hello
71
 	helloFile := global.Config.Admin.HelloFile
81
 	helloFile := global.Config.Admin.HelloFile
72
 	if helloFile != "" {
82
 	if helloFile != "" {