MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / loginOrThrow

Function loginOrThrow

console/src/api/materialize/auth.ts:38–62  ·  view source on GitHub ↗
(request: { payload: LoginRequest })

Source from the content-addressed store, hash-verified

36// Login API for to self-managed in password auth mode.
37// Throws if the API isn't supported for the deployment/auth mode.
38export async function loginOrThrow(request: { payload: LoginRequest }) {
39 const { authApiBasePath } = getApiClient();
40
41 const response = await fetch(`${authApiBasePath}/api/login`, {
42 method: "POST",
43 headers: {
44 "Content-Type": "application/json",
45 },
46 body: JSON.stringify(request.payload),
47 });
48
49 const responseText = await response.text();
50
51 if (!response.ok) {
52 if (response.status === 401) {
53 throw new Error("Invalid credentials", {
54 cause: { status: response.status },
55 });
56 }
57 throw new Error(responseText, {
58 cause: { status: response.status },
59 });
60 }
61 return responseText;
62}
63
64export async function hasActiveSession(): Promise<boolean> {
65 const { authApiBasePath } = getApiClient();

Callers

nothing calls this directly

Calls 2

getApiClientFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected