messages translated to pt

pull/2/head
Nilo Roberto C Paim 2021-11-03 07:24:54 -03:00
parent 8a55954d92
commit 6a1f3e00ba
2 changed files with 250 additions and 247 deletions

View File

@ -15,7 +15,7 @@ import (
func Version(c *fiber.Ctx) error { func Version(c *fiber.Ctx) error {
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"version": "1.0.1", "version": "1.0.2",
}) })
} }
@ -33,14 +33,14 @@ func Login(c *fiber.Ctx) error {
if user.Id == 0 { if user.Id == 0 {
c.Status(fiber.StatusNotFound) c.Status(fiber.StatusNotFound)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "User not found", "message": "Usuário não cadastrado",
}) })
} }
if err := bcrypt.CompareHashAndPassword(user.Password, []byte(data["password"])); err != nil { if err := bcrypt.CompareHashAndPassword(user.Password, []byte(data["password"])); err != nil {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Incorrect password", "message": "Senha incorreta",
}) })
} }
@ -63,7 +63,7 @@ func Login(c *fiber.Ctx) error {
if err != nil { if err != nil {
c.Status(fiber.StatusInternalServerError) c.Status(fiber.StatusInternalServerError)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Could't login", "message": "(A1) - Erro na geração do token",
}) })
} }
@ -93,7 +93,10 @@ func AddUser(c *fiber.Ctx) error {
database.DB.Create(&user) database.DB.Create(&user)
if user.Id == 0 { if user.Id == 0 {
return c.SendStatus(fiber.StatusFound) c.SendStatus(fiber.StatusFound)
return c.JSON(fiber.Map{
"message": "Usuário já cadastrado",
})
} }
c.SendStatus(fiber.StatusCreated) c.SendStatus(fiber.StatusCreated)
@ -108,7 +111,7 @@ func GetOwnUser(c *fiber.Ctx) error {
if err != nil { if err != nil {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Invalid authorization", "message": "Autorização inválida",
}) })
} }
@ -117,7 +120,7 @@ func GetOwnUser(c *fiber.Ctx) error {
if user.Id == 0 { if user.Id == 0 {
c.Status(fiber.StatusInternalServerError) c.Status(fiber.StatusInternalServerError)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Invalid token when should be ok", "message": "(A2) - Autorização inválida",
}) })
} }
@ -131,7 +134,7 @@ func GetAllUsers(c *fiber.Ctx) error {
if err != nil { if err != nil {
c.Status(fiber.StatusUnauthorized) c.Status(fiber.StatusUnauthorized)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Unauthenticated", "message": "Sem autorização",
}) })
} }
@ -140,7 +143,7 @@ func GetAllUsers(c *fiber.Ctx) error {
if len(users) == 0 { if len(users) == 0 {
c.Status(fiber.StatusUnauthorized) c.Status(fiber.StatusUnauthorized)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Unauthenticated", "message": "Sem autorização",
}) })
} }

View File

@ -20,7 +20,7 @@ func AddEvent(c *fiber.Ctx) error {
if err != nil { if err != nil {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Invalid authorization", "message": "Sem autorização",
}) })
} }
@ -32,7 +32,7 @@ func AddEvent(c *fiber.Ctx) error {
if err != nil { if err != nil {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Invalid value for Event Owner", "message": "Requisição inválida (usuário não informado)",
}) })
} }
@ -41,7 +41,7 @@ func AddEvent(c *fiber.Ctx) error {
if user.Id == 0 { if user.Id == 0 {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Event Owner not found", "message": "Requisição inválida (usuário inexistente)",
}) })
} }
@ -64,14 +64,14 @@ func AddEvent(c *fiber.Ctx) error {
if data["startDt"] == "" { if data["startDt"] == "" {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Start date not defined", "message": "Requisição inválida (sem data)",
}) })
} else { } else {
startdt, err = time.Parse(dateformat, data["startDt"]) startdt, err = time.Parse(dateformat, data["startDt"])
if err != nil { if err != nil {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Invalid value for start date", "message": "Requisição inválida (data inválida)",
}) })
} }
} }
@ -90,7 +90,7 @@ func AddEvent(c *fiber.Ctx) error {
if event.Id == 0 { if event.Id == 0 {
c.Status(fiber.StatusBadRequest) c.Status(fiber.StatusBadRequest)
return c.JSON(fiber.Map{ return c.JSON(fiber.Map{
"message": "Cannot create event", "message": "(E1) - Não foi possível criar o evento",
}) })
} }