UPDATE: fix bug
All checks were successful
Build and Release / release (push) Successful in 1m5s

This commit is contained in:
2026-04-17 15:44:34 +07:00
parent 903f2d709a
commit 324a91489c
4 changed files with 309 additions and 316 deletions

View File

@@ -1503,6 +1503,62 @@ const docTemplate = `{
} }
} }
} }
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the profile details of the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Update user profile",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Update Profile request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.UpdateProfileDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
} }
}, },
"/users/current/application": { "/users/current/application": {
@@ -1573,6 +1629,64 @@ const docTemplate = `{
} }
} }
}, },
"/users/current/password": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the password for the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Change user password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Change Password request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.ChangePasswordDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/users/{id}": { "/users/{id}": {
"get": { "get": {
"security": [ "security": [
@@ -1615,62 +1729,6 @@ const docTemplate = `{
} }
} }
}, },
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the profile details of the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Update user profile",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Update Profile request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.UpdateProfileDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
},
"delete": { "delete": {
"security": [ "security": [
{ {
@@ -1789,64 +1847,6 @@ const docTemplate = `{
} }
} }
}, },
"/users/{id}/password": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the password for the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Change user password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Change Password request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.ChangePasswordDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/users/{id}/restore": { "/users/{id}/restore": {
"patch": { "patch": {
"security": [ "security": [
@@ -1972,8 +1972,7 @@ const docTemplate = `{
"history-api_internal_dtos_request.ChangeRoleDto": { "history-api_internal_dtos_request.ChangeRoleDto": {
"type": "object", "type": "object",
"required": [ "required": [
"role_ids", "role_ids"
"user_id"
], ],
"properties": { "properties": {
"role_ids": { "role_ids": {
@@ -1982,9 +1981,6 @@ const docTemplate = `{
"items": { "items": {
"type": "string" "type": "string"
} }
},
"user_id": {
"type": "string"
} }
} }
}, },

View File

@@ -1496,6 +1496,62 @@
} }
} }
} }
},
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the profile details of the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Update user profile",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Update Profile request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.UpdateProfileDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
} }
}, },
"/users/current/application": { "/users/current/application": {
@@ -1566,6 +1622,64 @@
} }
} }
}, },
"/users/current/password": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the password for the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Change user password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Change Password request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.ChangePasswordDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/users/{id}": { "/users/{id}": {
"get": { "get": {
"security": [ "security": [
@@ -1608,62 +1722,6 @@
} }
} }
}, },
"put": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the profile details of the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Update user profile",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Update Profile request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.UpdateProfileDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
},
"delete": { "delete": {
"security": [ "security": [
{ {
@@ -1782,64 +1840,6 @@
} }
} }
}, },
"/users/{id}/password": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the password for the currently authenticated user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Users"
],
"summary": "Change user password",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Change Password request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_request.ChangePasswordDto"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/history-api_internal_dtos_response.CommonResponse"
}
}
}
}
},
"/users/{id}/restore": { "/users/{id}/restore": {
"patch": { "patch": {
"security": [ "security": [
@@ -1965,8 +1965,7 @@
"history-api_internal_dtos_request.ChangeRoleDto": { "history-api_internal_dtos_request.ChangeRoleDto": {
"type": "object", "type": "object",
"required": [ "required": [
"role_ids", "role_ids"
"user_id"
], ],
"properties": { "properties": {
"role_ids": { "role_ids": {
@@ -1975,9 +1974,6 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"user_id": {
"type": "string"
} }
} }
}, },

View File

@@ -21,11 +21,8 @@ definitions:
type: string type: string
minItems: 1 minItems: 1
type: array type: array
user_id:
type: string
required: required:
- role_ids - role_ids
- user_id
type: object type: object
history-api_internal_dtos_request.CreateTokenDto: history-api_internal_dtos_request.CreateTokenDto:
properties: properties:
@@ -1242,42 +1239,6 @@ paths:
summary: Get user by ID summary: Get user by ID
tags: tags:
- Users - Users
put:
consumes:
- application/json
description: Update the profile details of the currently authenticated user
parameters:
- description: User ID
in: path
name: id
required: true
type: string
- description: Update Profile request
in: body
name: request
required: true
schema:
$ref: '#/definitions/history-api_internal_dtos_request.UpdateProfileDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
security:
- BearerAuth: []
summary: Update user profile
tags:
- Users
/users/{id}/application: /users/{id}/application:
get: get:
consumes: consumes:
@@ -1328,43 +1289,6 @@ paths:
summary: Get user's media by user ID summary: Get user's media by user ID
tags: tags:
- Users - Users
/users/{id}/password:
patch:
consumes:
- application/json
description: Update the password for the currently authenticated user
parameters:
- description: User ID
in: path
name: id
required: true
type: string
- description: Change Password request
in: body
name: request
required: true
schema:
$ref: '#/definitions/history-api_internal_dtos_request.ChangePasswordDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
security:
- BearerAuth: []
summary: Change user password
tags:
- Users
/users/{id}/restore: /users/{id}/restore:
patch: patch:
consumes: consumes:
@@ -1451,6 +1375,42 @@ paths:
summary: Get current user profile summary: Get current user profile
tags: tags:
- Users - Users
put:
consumes:
- application/json
description: Update the profile details of the currently authenticated user
parameters:
- description: User ID
in: path
name: id
required: true
type: string
- description: Update Profile request
in: body
name: request
required: true
schema:
$ref: '#/definitions/history-api_internal_dtos_request.UpdateProfileDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
security:
- BearerAuth: []
summary: Update user profile
tags:
- Users
/users/current/application: /users/current/application:
get: get:
consumes: consumes:
@@ -1493,6 +1453,43 @@ paths:
summary: Get current user's media summary: Get current user's media
tags: tags:
- Users - Users
/users/current/password:
patch:
consumes:
- application/json
description: Update the password for the currently authenticated user
parameters:
- description: User ID
in: path
name: id
required: true
type: string
- description: Change Password request
in: body
name: request
required: true
schema:
$ref: '#/definitions/history-api_internal_dtos_request.ChangePasswordDto'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/history-api_internal_dtos_response.CommonResponse'
security:
- BearerAuth: []
summary: Change user password
tags:
- Users
securityDefinitions: securityDefinitions:
BearerAuth: BearerAuth:
description: Type "Bearer " followed by a space and JWT token. description: Type "Bearer " followed by a space and JWT token.

View File

@@ -124,7 +124,11 @@ func (v *verificationService) DeleteVerification(ctx context.Context, claims *re
} }
shoudDelete := false shoudDelete := false
if slices.Contains(claims.Roles, constants.ADMIN) || slices.Contains(claims.Roles, constants.MOD) || verification.User.ID == claims.UId { if slices.Contains(claims.Roles, constants.ADMIN) || slices.Contains(claims.Roles, constants.MOD) {
shoudDelete = true
}
if verification.User.ID == claims.UId && verification.Status == constants.StatusPending {
shoudDelete = true shoudDelete = true
} }
@@ -132,7 +136,7 @@ func (v *verificationService) DeleteVerification(ctx context.Context, claims *re
return fiber.NewError(fiber.StatusForbidden, "You don't have permission to delete this verification") return fiber.NewError(fiber.StatusForbidden, "You don't have permission to delete this verification")
} }
err = v.mediaRepo.Delete(ctx, verificationIdUUID) err = v.verificationRepo.Delete(ctx, verificationIdUUID)
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error()) return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} }