mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 02:18:50 +00:00
Adds the following endpoints: - `PUT /clients/:id` for updating the `name` - `PUT /clients/:client_id/verify` for verifying a client - `PUT /clients/:client_id/unverify` for unverifying a client - `GET /clients` for listing clients in an account - `GET /clients/:id` for getting a single client - `DELETE /clients/:id` for deleting a client Related: #8081
62 lines
1.5 KiB
Elixir
62 lines
1.5 KiB
Elixir
defmodule API.FallbackController do
|
|
use Phoenix.Controller
|
|
|
|
def call(conn, {:error, :not_found}) do
|
|
conn
|
|
|> put_status(:not_found)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:"404")
|
|
end
|
|
|
|
def call(conn, {:error, :unauthorized}) do
|
|
conn
|
|
|> put_status(:unauthorized)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:"401")
|
|
end
|
|
|
|
def call(conn, {:error, {:unauthorized, details}}) do
|
|
reason = Keyword.get(details, :reason, "Unauthorized")
|
|
|
|
conn
|
|
|> put_status(:unauthorized)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:"401", reason: reason)
|
|
end
|
|
|
|
def call(conn, {:error, :bad_request}) do
|
|
conn
|
|
|> put_status(:bad_request)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:"400")
|
|
end
|
|
|
|
def call(conn, {:error, :unprocessable_entity}) do
|
|
conn
|
|
|> put_status(:unprocessable_entity)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:"422")
|
|
end
|
|
|
|
def call(conn, {:error, :seats_limit_reached}) do
|
|
conn
|
|
|> put_status(:unprocessable_entity)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:error, reason: "Seat Limit Reached")
|
|
end
|
|
|
|
def call(conn, {:error, :service_accounts_limit_reached}) do
|
|
conn
|
|
|> put_status(:unprocessable_entity)
|
|
|> put_view(json: API.ErrorJSON)
|
|
|> render(:error, reason: "Service Accounts Limit Reached")
|
|
end
|
|
|
|
def call(conn, {:error, %Ecto.Changeset{} = changeset}) do
|
|
conn
|
|
|> put_status(:unprocessable_entity)
|
|
|> put_view(json: API.ChangesetJSON)
|
|
|> render(:error, status: 422, changeset: changeset)
|
|
end
|
|
end
|