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

View File

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

View File

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

View File

@ -5,8 +5,8 @@ import (
"time" "time"
) )
// AnonymousUser 调试模式下的用户 // AnonymousUser 调试模式下的用户,这里使用 string 是防止 swag go 解析为 enum
const AnonymousUser ID = "anonymous" const AnonymousUser string = "anonymous"
type Token struct { type Token struct {
Aud string `json:"aud"` 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) { 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) var jwtIdToken = new(user.User)
if a.config.Debug.Enabled { if a.config.Debug.Enabled {