mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-13 08:24:22 +08:00
Do not perform requests for offline teams
This commit is contained in:
parent
fdd2d2c2f2
commit
b918f8ab47
1 changed files with 16 additions and 8 deletions
|
@ -314,6 +314,13 @@ defmodule Livebook.Teams.Requests do
|
||||||
defp add_team_auth(req, nil), do: req
|
defp add_team_auth(req, nil), do: req
|
||||||
|
|
||||||
defp add_team_auth(req, team) do
|
defp add_team_auth(req, team) do
|
||||||
|
if team.offline do
|
||||||
|
Req.Request.append_request_steps(req,
|
||||||
|
unauthorized: fn req ->
|
||||||
|
{req, Req.Response.new(status: 401)}
|
||||||
|
end
|
||||||
|
)
|
||||||
|
else
|
||||||
token =
|
token =
|
||||||
if team.user_id do
|
if team.user_id do
|
||||||
"#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
|
"#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
|
||||||
|
@ -323,6 +330,7 @@ defmodule Livebook.Teams.Requests do
|
||||||
|
|
||||||
Req.Request.merge_options(req, auth: {:bearer, token})
|
Req.Request.merge_options(req, auth: {:bearer, token})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp request(req, opts) do
|
defp request(req, opts) do
|
||||||
case Req.request(req, opts) do
|
case Req.request(req, opts) do
|
||||||
|
@ -339,7 +347,7 @@ defmodule Livebook.Teams.Requests do
|
||||||
|
|
||||||
{:ok, %{status: 401}} ->
|
{:ok, %{status: 401}} ->
|
||||||
{:transport_error,
|
{:transport_error,
|
||||||
"You are not authorized to perform this action, make sure you have the access or you are not in a Livebook Agent instance"}
|
"You are not authorized to perform this action, make sure you have the access or you are not in a Livebook Agent/Offline instance"}
|
||||||
|
|
||||||
_otherwise ->
|
_otherwise ->
|
||||||
{:transport_error, @error_message}
|
{:transport_error, @error_message}
|
||||||
|
|
Loading…
Add table
Reference in a new issue