fix🐛: Adjust the demo environment configuration

This commit is contained in:
zhangwenjian committed 2022-11-09 17:35:16 +08:00
1 parent 42f3025217
commit ddd97d5a9e
4 files changed
+7 -30

No files matched your search

+3 -18
View File
@@ -2,7 +2,6 @@ package apis
import (
"github.com/gin-gonic/gin/binding"
"github.com/go-admin-team/go-admin-core/sdk/config"
"go-admin/app/admin/models"
"golang.org/x/crypto/bcrypt"
"net/http"
@@ -313,19 +312,12 @@ func (e SysUser) ResetPwd(c *gin.Context) {
//数据权限检查
p := actions.GetPermissionFromContext(c)
if req.UserId == 1 && config.ApplicationConfig.Mode == "demo" {
req.Password = "123456"
}
err = s.ResetPwd(&req, p)
if err != nil {
e.Logger.Error(err)
return
}
if req.UserId == 1 && config.ApplicationConfig.Mode == "demo" {
e.OK(req.GetId(), "admin:现在使用的预览环境,休想改掉我!否则会影响其他朋友体验的哦!可以创建其他用户体验该功能!")
} else {
e.OK(req.GetId(), "更新成功")
}
e.OK(req.GetId(), "更新成功")
}
// UpdatePwd
@@ -354,10 +346,6 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
// 数据权限检查
p := actions.GetPermissionFromContext(c)
if user.GetUserId(c) == 1 && config.ApplicationConfig.Mode == "demo" {
req.NewPassword = "123456"
}
var hash []byte
if hash, err = bcrypt.GenerateFromPassword([]byte(req.NewPassword), bcrypt.DefaultCost); err != nil {
req.NewPassword = string(hash)
@@ -369,11 +357,8 @@ func (e SysUser) UpdatePwd(c *gin.Context) {
e.Error(http.StatusForbidden, err, "密码修改失败")
return
}
if user.GetUserId(c) == 1 && config.ApplicationConfig.Mode == "demo" {
e.OK(nil, "admin:现在使用的预览环境,休想改掉我!否则会影响其他朋友体验的哦!可以创建其他用户体验该功能!")
} else {
e.OK(nil, "密码修改成功")
}
e.OK(nil, "密码修改成功")
}
// GetProfile
+1 -5
View File
@@ -1,7 +1,6 @@
package handler
import (
"fmt"
"go-admin/app/admin/models"
"go-admin/common"
"net/http"
@@ -16,8 +15,6 @@ import (
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
"github.com/go-admin-team/go-admin-core/sdk/pkg/response"
"github.com/mssola/user_agent"
gaConfig "go-admin/config"
"go-admin/common/global"
)
@@ -119,8 +116,7 @@ func LoginLogToDB(c *gin.Context, status string, msg string, username string) {
ua := user_agent.New(c.Request.UserAgent())
l["ipaddr"] = common.GetClientIP(c)
fmt.Println("gaConfig.ExtConfig.AMap.Key", gaConfig.ExtConfig.AMap.Key)
l["loginLocation"] = pkg.GetLocation(common.GetClientIP(c),gaConfig.ExtConfig.AMap.Key)
l["loginLocation"] = "" // pkg.GetLocation(common.GetClientIP(c),gaConfig.ExtConfig.AMap.Key)
l["loginTime"] = pkg.GetCurrentTime()
l["status"] = status
l["remark"] = c.Request.UserAgent()
+2 -2
View File
@@ -14,6 +14,7 @@ const (
)
func InitMiddleware(r *gin.Engine) {
r.Use(DemoEvn())
// 数据库链接
r.Use(WithContextDb)
// 日志处理
@@ -26,10 +27,9 @@ func InitMiddleware(r *gin.Engine) {
r.Use(Options)
// Secure is a middleware function that appends security
r.Use(Secure)
//r.Use(DemoEvn())
// 链路追踪
//r.Use(middleware.Trace())
sdk.Runtime.SetMiddleware(JwtTokenCheck, (*jwt.GinJWTMiddleware).MiddlewareFunc)
sdk.Runtime.SetMiddleware(RoleCheck, AuthCheckRole())
sdk.Runtime.SetMiddleware(PermissionCheck, actions.PermissionAction())
}
}
+1 -5
View File
@@ -4,10 +4,8 @@ import (
"bufio"
"bytes"
"encoding/json"
"fmt"
"go-admin/app/admin/service/dto"
"go-admin/common"
gaConfig "go-admin/config"
"io"
"io/ioutil"
"net/http"
@@ -18,7 +16,6 @@ import (
"github.com/go-admin-team/go-admin-core/sdk"
"github.com/go-admin-team/go-admin-core/sdk/api"
"github.com/go-admin-team/go-admin-core/sdk/config"
"github.com/go-admin-team/go-admin-core/sdk/pkg"
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
"go-admin/common/global"
@@ -109,8 +106,7 @@ func SetDBOperLog(c *gin.Context, clientIP string, statusCode int, reqUri string
l["_fullPath"] = c.FullPath()
l["operUrl"] = reqUri
l["operIp"] = clientIP
fmt.Println("gaConfig.ExtConfig.AMap.Key", gaConfig.ExtConfig.AMap.Key)
l["operLocation"] = pkg.GetLocation(clientIP, gaConfig.ExtConfig.AMap.Key)
l["operLocation"] = "" // pkg.GetLocation(clientIP, gaConfig.ExtConfig.AMap.Key)
l["operName"] = user.GetUserName(c)
l["requestMethod"] = reqMethod
l["operParam"] = body