feat: 新增第三方登录认证和管理
This commit is contained in:
@@ -46,25 +46,31 @@ func LogOperate(options collectlogs.Options) func(http.Handler) http.Handler {
|
||||
lastDotIndex := strings.LastIndex(funcName, "/")
|
||||
funcName = funcName[lastDotIndex+1:]
|
||||
|
||||
// 用户名
|
||||
username := ctx.LoginUserToUserName(r)
|
||||
|
||||
// 获取登录用户信息
|
||||
loginUser, err := ctx.LoginUser(r)
|
||||
if err != nil {
|
||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
// 解析ip地址
|
||||
ip := strings.Split(r.RemoteAddr, ":")[0]
|
||||
ipaddr := ip2region.ClientIP(ip)
|
||||
location := ip2region.RealAddressByIp(ipaddr)
|
||||
|
||||
// 操作日志记录
|
||||
operLog := model.SysLogOperate{
|
||||
Title: options.Title,
|
||||
BusinessType: options.BusinessType,
|
||||
OperatorType: collectlogs.OPERATOR_TYPE_MANAGE,
|
||||
OperatorType: loginUser.User.UserType,
|
||||
Method: funcName,
|
||||
OperURL: r.RequestURI,
|
||||
RequestMethod: r.Method,
|
||||
OperIP: ipaddr,
|
||||
OperLocation: location,
|
||||
OperName: username,
|
||||
DeptName: "",
|
||||
OperName: loginUser.User.UserName,
|
||||
DeptName: loginUser.User.Dept.DeptName,
|
||||
TenantName: loginUser.User.Tenant.TenantName,
|
||||
TenantID: loginUser.User.Tenant.TenantID,
|
||||
}
|
||||
|
||||
// 是否需要保存request,参数和值
|
||||
@@ -120,8 +126,15 @@ func LogOperate(options collectlogs.Options) func(http.Handler) http.Handler {
|
||||
contentDisposition := w.Header().Get("Content-Disposition")
|
||||
contentType := w.Header().Get("Content-Type")
|
||||
content := contentType + contentDisposition
|
||||
msg := fmt.Sprintf(`{"status":"%s","size":"%s","content-type":"%s"}`, status, size, content)
|
||||
operLog.OperMsg = msg
|
||||
msgByte, err := json.Marshal(map[string]any{
|
||||
"status": status,
|
||||
"size": size,
|
||||
"content-type": content,
|
||||
})
|
||||
if err != nil {
|
||||
operLog.OperMsg = ""
|
||||
}
|
||||
operLog.OperMsg = string(msgByte)
|
||||
}
|
||||
|
||||
// 日志记录时间
|
||||
|
||||
Reference in New Issue
Block a user