change default userIdKey to "id"
This commit is contained in:
		
							parent
							
								
									b1796dad4d
								
							
						
					
					
						commit
						a1f5f72181
					
				
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							@ -3,7 +3,7 @@ module apigo.cc/gojs/service
 | 
			
		||||
go 1.18
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	apigo.cc/gojs v0.0.9
 | 
			
		||||
	apigo.cc/gojs v0.0.12
 | 
			
		||||
	apigo.cc/gojs/console v0.0.2
 | 
			
		||||
	apigo.cc/gojs/http v0.0.3
 | 
			
		||||
	apigo.cc/gojs/util v0.0.8
 | 
			
		||||
@ -32,7 +32,7 @@ require (
 | 
			
		||||
	github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
 | 
			
		||||
	github.com/shirou/gopsutil/v3 v3.24.5 // indirect
 | 
			
		||||
	github.com/shoenig/go-m1cpu v0.1.6 // indirect
 | 
			
		||||
	github.com/ssgo/tool v0.4.27 // indirect
 | 
			
		||||
	github.com/ssgo/tool v0.4.28 // indirect
 | 
			
		||||
	github.com/tklauser/go-sysconf v0.3.14 // indirect
 | 
			
		||||
	github.com/tklauser/numcpus v0.9.0 // indirect
 | 
			
		||||
	github.com/yusufpapurcu/wmi v1.2.4 // indirect
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ func initConfig(opt *gojs.Obj, logger *log.Logger, vm *goja.Runtime) {
 | 
			
		||||
		s.SetWorkPath(u.String(startPath))
 | 
			
		||||
	}
 | 
			
		||||
	// 处理配置
 | 
			
		||||
	serviceConfig = Config{"Session", "Device", "Client", "userId", "", 3600, "auth failed", "verify failed", "too many requests", nil, "", map[string]string{}, map[string]string{}, map[string]string{}}
 | 
			
		||||
	serviceConfig = Config{"Session", "Device", "Client", "id", "", 3600, "auth failed", "verify failed", "too many requests", nil, "", map[string]string{}, map[string]string{}, map[string]string{}}
 | 
			
		||||
	if errs := config.LoadConfig("service", &serviceConfig); errs != nil && len(errs) > 0 {
 | 
			
		||||
		panic(vm.NewGoError(errs[0]))
 | 
			
		||||
	}
 | 
			
		||||
@ -237,6 +237,9 @@ func init() {
 | 
			
		||||
				s.SetOutFilter(func(in map[string]any, request *s.Request, response *s.Response, out any, logger *log.Logger) (newOut any, isOver bool) {
 | 
			
		||||
					if strings.HasPrefix(response.Header().Get("Content-Type"), "text/html") {
 | 
			
		||||
						outStr := u.String(out)
 | 
			
		||||
						if strings.Contains(outStr, "let _watchWS = null") {
 | 
			
		||||
							return nil, false
 | 
			
		||||
						}
 | 
			
		||||
						// 注入自动刷新的代码
 | 
			
		||||
						outStr = strings.ReplaceAll(outStr, "</html>", `<script>
 | 
			
		||||
	let _watchWS = null
 | 
			
		||||
@ -305,6 +308,7 @@ func init() {
 | 
			
		||||
				panic(vm.NewGoError(errors.New("server not started")))
 | 
			
		||||
			}
 | 
			
		||||
			server.Stop()
 | 
			
		||||
			s.ResetAllSets()
 | 
			
		||||
			return nil
 | 
			
		||||
		},
 | 
			
		||||
		"uniqueId": func(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value {
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,7 @@ interface Config {
 | 
			
		||||
    sessionKey: string                          // HTTP头和Cookie中SessionID的Key,客户端没有传递时服务端自动生成,Header的优先级高于Cookie,默认为 Session, 设置为空时表示不使用
 | 
			
		||||
    deviceKey: string                           // 标识设备ID的Key,客户端没有传递时服务端自动生成,Header的优先级高于Cookie,默认为 Device, 设置为空时表示不使用
 | 
			
		||||
    clientKey: string                           // 标识客户端的Key,默认为 Client,对应的Header头为 ClientName 和 ClientVersion
 | 
			
		||||
    userIdKey: string                           // session中userID的Key,用于在日志中记录userId信息,默认为 userId
 | 
			
		||||
    userIdKey: string                           // session中userID的Key,用于在日志中记录用户ID信息,默认为 id
 | 
			
		||||
    sessionProvider: string                     // 指定一个redis连接(例如:redis://:sskey加密的密码@127.0.0.1:6379/15),默认使用内存存储
 | 
			
		||||
    sessionTimeout: number                      // session过期时间,单位 秒,默认为 3600秒
 | 
			
		||||
    authFieldMessage: string | Object           // 身份验证失败时的消息,默认为 auth failed,可以设置对象来返回JSON,可以使用模版 {{TARGET_AUTHLEVEL}}、{{USER_AUTHLEVEL}}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user