Skip to content

Commit

Permalink
fix: do not use access token for admin api
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed May 19, 2024
1 parent 3b6b558 commit c0b6c85
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions lib/supabase/go_true/admin_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Supabase.GoTrue.AdminHandler do
end

def invite_user(%Client{} = client, email, %InviteUserParams{} = opts) do
headers = Fetcher.apply_client_headers(client, nil, %{"redirect_to" => opts.redirect_to})
headers = Fetcher.apply_client_headers(client, client.conn.api_key, %{"redirect_to" => opts.redirect_to})
body = %{email: email, data: opts.data}

client
Expand All @@ -33,23 +33,23 @@ defmodule Supabase.GoTrue.AdminHandler do
end

def generate_link(%Client{} = client, %{type: _, redirect_to: redirect_to} = params) do
headers = Fetcher.apply_client_headers(client, nil, %{"redirect_to" => redirect_to})
headers = Fetcher.apply_client_headers(client, client.conn.api_key, %{"redirect_to" => redirect_to})

client
|> Client.retrieve_auth_url(@generate_link)
|> Fetcher.post(params, headers, resolve_json: true)
end

def create_user(%Client{} = client, params) do
headers = Fetcher.apply_client_headers(client)
headers = Fetcher.apply_client_headers(client, client.conn.api_key)

client
|> Client.retrieve_auth_url(@users)
|> Fetcher.post(params, headers, resolve_json: true)
end

def delete_user(%Client{} = client, id, params) do
headers = Fetcher.apply_client_headers(client)
headers = Fetcher.apply_client_headers(client, client.conn.api_key)
body = %{should_soft_delete: params[:should_soft_delete] || false}
uri = single_user_endpoint(id)

Expand All @@ -59,7 +59,7 @@ defmodule Supabase.GoTrue.AdminHandler do
end

def get_user(%Client{} = client, id) do
headers = Fetcher.apply_client_headers(client)
headers = Fetcher.apply_client_headers(client, client.conn.api_key)
uri = single_user_endpoint(id)

client
Expand All @@ -73,7 +73,7 @@ defmodule Supabase.GoTrue.AdminHandler do
per_page: to_string(Map.get(params, :per_page, nil))
}

headers = Fetcher.apply_client_headers(client)
headers = Fetcher.apply_client_headers(client, client.conn.api_key)

client
|> Client.retrieve_auth_url(@users)
Expand All @@ -87,7 +87,7 @@ defmodule Supabase.GoTrue.AdminHandler do
end

def update_user(%Client{} = client, id, params) do
headers = Fetcher.apply_client_headers(client)
headers = Fetcher.apply_client_headers(client, client.conn.api_key)
uri = single_user_endpoint(id)

client
Expand Down
2 changes: 1 addition & 1 deletion lib/supabase/go_true/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ defmodule Supabase.GoTrue.Plug do

conn
|> renew_session()
|> redirect(to: @not_authenticated_path )
|> redirect(to: @not_authenticated_path)
end


Expand Down
2 changes: 1 addition & 1 deletion lib/supabase/go_true/user_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ defmodule Supabase.GoTrue.UserHandler do
endpoint = Client.retrieve_auth_url(client, @resend_signup_uri)
endpoint = append_query(endpoint, %{redirect_to: opts[:redirect_to]})

with {:ok, _} <- Fetcher.post(endpoint, body, headers) |> IO.inspect() do
with {:ok, _} <- Fetcher.post(endpoint, body, headers) do
:ok
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule SupabaseAuth.MixProject do
use Mix.Project

@version "0.3.6"
@version "0.3.7"
@source_url "https://github.com/zoedsoupe/gotrue-ex"

def project do
Expand Down

0 comments on commit c0b6c85

Please sign in to comment.