Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,18 @@ public function updateUser(string $bearerUserToken, string $email = null, string
return $this->service->executeHttpRequest('PUT', $uri, $options);
}

}
/**
* Delete the user, need service_role secret
* @param $id String The user id
* @return array|object|null
*/
public function deleteUser($id)
{
$uri = $this->service->getUriBase($this->suffix . 'admin/users/' . $id);
$options = [
'headers' => $this->service->getHeaders()
];
return $this->service->executeHttpRequest('DELETE', $uri, $options);
}

}
3 changes: 2 additions & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __construct(string $apiKey, string $uriBase)

$this->httpClient = new \GuzzleHttp\Client();
$this->headers['apikey'] = $this->apiKey;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its been a while since ive used supabase, but is this line needed? i cant remember any use of an apikey header

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, without it you'll get

{"message":"No API key found in request","hint":"No `apikey` request header or url param was found."}

$this->headers['Authorization'] = 'Bearer ' . $this->apiKey;
}

/**
Expand Down Expand Up @@ -221,4 +222,4 @@ public function executeHttpRequest(string $method, string $uri, array $options)
throw $e;
}
}
}
}