Updating versions and changing log system
Some checks failed
continuous-integration/drone Build encountered an error
Some checks failed
continuous-integration/drone Build encountered an error
This commit is contained in:
@@ -44,3 +44,36 @@ func (h Handlers) AccountGet(c *fiber.Ctx) error {
|
||||
|
||||
return c.JSON(account)
|
||||
}
|
||||
|
||||
// AccountGet godoc
|
||||
// @Summary Get accounts
|
||||
// @Description Requires Authorization-header with role "admin".
|
||||
// @Description Example: Authorization: bearer xxx
|
||||
// @Description Where "xxx" is a valid JWT token
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} []db.Account
|
||||
// @Failure 401 {object} []ResJSONError
|
||||
// @Failure 403 {object} []ResJSONError
|
||||
// @Failure 415 {object} []ResJSONError
|
||||
// @Failure 500 {object} []ResJSONError
|
||||
// @Router /accounts [get]
|
||||
func (h Handlers) AccountsGet(c *fiber.Ctx) error {
|
||||
accountID := c.Params("accountID")
|
||||
|
||||
authErr := h.RequireAdminRole(c)
|
||||
if authErr != nil {
|
||||
return c.Status(403).JSON([]ResJSONError{{Error: authErr.Error()}})
|
||||
}
|
||||
|
||||
account, accountErr := h.Db.AccountGet(accountID, "", "")
|
||||
if accountErr != nil {
|
||||
if accountErr.Error() == "no rows in result set" {
|
||||
return c.Status(404).JSON([]ResJSONError{{Error: "No account found for given accountID"}})
|
||||
} else {
|
||||
return c.Status(500).JSON([]ResJSONError{{Error: accountErr.Error()}})
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(account)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user