From 45e7d9f99aafec4f8b1b3c308da7f631758f7421 Mon Sep 17 00:00:00 2001 From: Nilo Roberto C Paim Date: Fri, 1 Sep 2023 08:25:18 -0300 Subject: [PATCH] changes on user creation --- .env | 32 ++++++++++++++++---------------- .gitignore | 2 ++ controllers/authController.go | 16 +++------------- main.go | 3 +-- 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/.env b/.env index 31fbb3a..99557f8 100644 --- a/.env +++ b/.env @@ -12,21 +12,21 @@ API_SECRET=nyEX8BZ44KqTXeV2 #DB_PORT=5432 # DB configuration HOMOLOGAÇÃO -API_PORT=8111 -API_RELEASE="Homologação" -DB_HOST=191.252.214.157 -DB_DRIVER=postgres -DB_USER=pcasthomolog -DB_PASSWORD=@407Smc837 -DB_NAME=pcasthomolog -DB_PORT=5432 +#API_PORT=8111 +#API_RELEASE="Homologação" +#DB_HOST=191.252.214.157 +#DB_DRIVER=postgres +#DB_USER=pcasthomolog +#DB_PASSWORD=@407Smc837 +#DB_NAME=pcasthomolog +#DB_PORT=5432 # DB configuration PRODUÇÃO -#API_PORT=8112 -#API_RELEASE="" -#DB_HOST=177.153.50.98 -#DB_DRIVER=postgres -#DB_USER=pcast -#DB_PASSWORD=@407Smc837 -#DB_NAME=pcast -#DB_PORT=5432 +API_PORT=8112 +API_RELEASE="" +DB_HOST=177.153.50.98 +DB_DRIVER=postgres +DB_USER=pcast +DB_PASSWORD=@407Smc837 +DB_NAME=pcast +DB_PORT=5432 diff --git a/.gitignore b/.gitignore index 69c27cc..9dd6d3d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ api api.exe +.env + pcast.db api-homolog.log .gitignore diff --git a/controllers/authController.go b/controllers/authController.go index adf2b73..ef1b886 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -85,15 +85,7 @@ func AddUser(c *fiber.Ctx) error { return fiber.ErrBadRequest } - // If I don't receive an auth field in the request, I need to verify if the sender is logged - if data["auth"] == "" { - _, err := utils.ProcessToken(c) - if err != nil { - return fiber.ErrUnauthorized - } - } - - if data["name"] == "" || data["email"] == "" || data["password"] == "" || data["channel"] == "" { + if data["name"] == "" || data["email"] == "" || data["password"] == "" || data["channel"] == "" || data["usertype"] == "" || data["companyname"] == "" { return fiber.ErrBadRequest } @@ -108,7 +100,7 @@ func AddUser(c *fiber.Ctx) error { UserType: data["usertype"], Blocked: "N", Cancelled: "N", - CreatedBy: data["creator"], + CreatedBy: data["createdby"], } database.DB.Create(&user) @@ -117,9 +109,7 @@ func AddUser(c *fiber.Ctx) error { return fiber.ErrNotAcceptable } - return c.JSON(fiber.Map{ - "user": user, - }) + return c.JSON(user) } // GetOwnUser - Returns the current user diff --git a/main.go b/main.go index 97f13da..2348c69 100644 --- a/main.go +++ b/main.go @@ -39,8 +39,7 @@ func main() { }) app.Use(logger.New(logger.Config{ - // Output: file, - Format: "[${ip}]:${port} ${status} - ${method} ${path} ${reqHeaders}\n", + Output: file, })) app.Use(cors.New(cors.Config{