From 44d0d0c9735fb07549e8130752c23f1205b67bb7 Mon Sep 17 00:00:00 2001 From: AzenKain Date: Mon, 30 Mar 2026 16:49:37 +0700 Subject: [PATCH] UPDATE: Fix bug auth --- cmd/api/main.go | 2 -- docs/docs.go | 4 ++-- docs/swagger.json | 5 ----- docs/swagger.yaml | 4 ---- internal/services/authService.go | 6 +++--- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 38ee65e..30f9b40 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -114,9 +114,7 @@ func StartServer() { // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html -// @host history-api.kain.id.vn // @BasePath / -// @schemes https http // @securityDefinitions.apikey BearerAuth // @in header diff --git a/docs/docs.go b/docs/docs.go index d52fba0..7528405 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1119,9 +1119,9 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "1.0", - Host: "history-api.kain.id.vn", + Host: "", BasePath: "/", - Schemes: []string{"https", "http"}, + Schemes: []string{}, Title: "History API", Description: "This is a sample server for History API.", InfoInstanceName: "swagger", diff --git a/docs/swagger.json b/docs/swagger.json index cd21826..776e271 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1,8 +1,4 @@ { - "schemes": [ - "https", - "http" - ], "swagger": "2.0", "info": { "description": "This is a sample server for History API.", @@ -19,7 +15,6 @@ }, "version": "1.0" }, - "host": "history-api.kain.id.vn", "basePath": "/", "paths": { "/auth/forgot-password": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 4bb82e3..60e0079 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -163,7 +163,6 @@ definitions: - TokenEmailVerify - TokenMagicLink - TokenRefreshToken -host: history-api.kain.id.vn info: contact: email: support@swagger.io @@ -730,9 +729,6 @@ paths: summary: Get current user profile tags: - Users -schemes: -- https -- http securityDefinitions: BearerAuth: description: Type "Bearer " followed by a space and JWT token. diff --git a/internal/services/authService.go b/internal/services/authService.go index 18d110a..c9be612 100644 --- a/internal/services/authService.go +++ b/internal/services/authService.go @@ -227,7 +227,7 @@ func (a *authService) Signup(ctx context.Context, dto *request.SignUpDto) (*resp } user, err := a.userRepo.GetByEmail(ctx, dto.Email) - if err != nil { + if err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, fiber.NewError(fiber.StatusInternalServerError, err.Error()) } if user != nil { @@ -478,7 +478,7 @@ func (a *authService) CreateToken(ctx context.Context, dto *request.CreateTokenD } user, err := a.userRepo.GetByEmail(ctx, dto.Email) - if err != nil { + if err != nil && !errors.Is(err, sql.ErrNoRows) { return fiber.NewError(fiber.StatusInternalServerError, "Internal Server Error") } @@ -533,7 +533,7 @@ func (a *authService) VerifyToken(ctx context.Context, dto *request.VerifyTokenD } user, err := a.userRepo.GetByEmail(ctx, dto.Email) - if err != nil { + if err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, fiber.NewError(fiber.StatusInternalServerError, "Internal Server Error") }