This commit is contained in:
ivamp 2024-12-10 18:35:45 +08:00
parent 1ce37a91ce
commit b15fa3f709
5 changed files with 12 additions and 36 deletions

View File

@ -1002,7 +1002,7 @@ const docTemplate = `{
],
"properties": {
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
}
}
},
@ -1219,7 +1219,7 @@ const docTemplate = `{
"type": "string"
},
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
}
}
},
@ -1236,7 +1236,7 @@ const docTemplate = `{
"type": "string"
},
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
},
"workspace": {
"$ref": "#/definitions/entity.Workspace"
@ -1294,15 +1294,6 @@ const docTemplate = `{
"type": "string"
}
}
},
"user.ID": {
"type": "string",
"enum": [
"anonymous"
],
"x-enum-varnames": [
"AnonymousUser"
]
}
},
"securityDefinitions": {

View File

@ -993,7 +993,7 @@
],
"properties": {
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
}
}
},
@ -1210,7 +1210,7 @@
"type": "string"
},
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
}
}
},
@ -1227,7 +1227,7 @@
"type": "string"
},
"user_id": {
"$ref": "#/definitions/user.ID"
"type": "string"
},
"workspace": {
"$ref": "#/definitions/entity.Workspace"
@ -1285,15 +1285,6 @@
"type": "string"
}
}
},
"user.ID": {
"type": "string",
"enum": [
"anonymous"
],
"x-enum-varnames": [
"AnonymousUser"
]
}
},
"securityDefinitions": {

View File

@ -2,7 +2,7 @@ definitions:
dto.AddWorkspaceMemberRequest:
properties:
user_id:
$ref: '#/definitions/user.ID'
type: string
required:
- user_id
type: object
@ -145,7 +145,7 @@ definitions:
updated_at:
type: string
user_id:
$ref: '#/definitions/user.ID'
type: string
type: object
entity.WorkspaceMember:
properties:
@ -156,7 +156,7 @@ definitions:
updated_at:
type: string
user_id:
$ref: '#/definitions/user.ID'
type: string
workspace:
$ref: '#/definitions/entity.Workspace'
workspace_id:
@ -194,12 +194,6 @@ definitions:
message:
type: string
type: object
user.ID:
enum:
- anonymous
type: string
x-enum-varnames:
- AnonymousUser
info:
contact: {}
title: API Docs

View File

@ -5,8 +5,8 @@ import (
"time"
)
// AnonymousUser 调试模式下的用户
const AnonymousUser ID = "anonymous"
// AnonymousUser 调试模式下的用户,这里使用 string 是防止 swag go 解析为 enum
const AnonymousUser string = "anonymous"
type Token struct {
Aud string `json:"aud"`

View File

@ -71,7 +71,7 @@ func (a *Service) SetUser(ctx context.Context, user *user.User) context.Context
}
func (a *Service) parseUserJWT(tokenType constants.JwtTokenTypes, jwtToken string) (*user.User, error) {
var sub = user.AnonymousUser
var sub = user.ID(user.AnonymousUser)
var jwtIdToken = new(user.User)
if a.config.Debug.Enabled {