mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-13 16:05:00 +00:00
add email to cli resource fetching
This commit is contained in:
+4
-4
@@ -1,5 +1,5 @@
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import { colors, setClient, UserService } from "./deps.ts";
|
||||
import { colors, GlobalUserInfo, setClient, UserService } from "./deps.ts";
|
||||
import { loginInteractive, tryGetLoginInfo } from "./login.ts";
|
||||
import { GlobalOptions } from "./types.ts";
|
||||
import {
|
||||
@@ -60,7 +60,7 @@ export async function resolveWorkspace(
|
||||
}
|
||||
}
|
||||
|
||||
export async function requireLogin(opts: GlobalOptions) {
|
||||
export async function requireLogin(opts: GlobalOptions): Promise<GlobalUserInfo> {
|
||||
const workspace = await resolveWorkspace(opts);
|
||||
|
||||
let token = await tryGetLoginInfo(opts);
|
||||
@@ -71,7 +71,7 @@ export async function requireLogin(opts: GlobalOptions) {
|
||||
setClient(token, workspace.remote.substring(0, workspace.remote.length - 1));
|
||||
|
||||
try {
|
||||
await UserService.globalWhoami();
|
||||
return await UserService.globalWhoami();
|
||||
} catch {
|
||||
console.log(
|
||||
"! Could not reach API given existing credentials. Attempting to reauth...",
|
||||
@@ -88,7 +88,7 @@ export async function requireLogin(opts: GlobalOptions) {
|
||||
token,
|
||||
workspace.remote.substring(0, workspace.remote.length - 1),
|
||||
);
|
||||
await UserService.globalWhoami();
|
||||
return await UserService.globalWhoami();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -13,7 +13,7 @@ async function pull(opts: GlobalOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
await requireLogin(opts);
|
||||
const userInfo = await requireLogin(opts);
|
||||
const list: {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -26,6 +26,12 @@ async function pull(opts: GlobalOptions) {
|
||||
comments: never[];
|
||||
}[] = await fetch(
|
||||
"https://hub.windmill.dev/resource_types/list",
|
||||
{
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"X-email": userInfo.email,
|
||||
},
|
||||
},
|
||||
)
|
||||
.then((r) => r.json())
|
||||
.then((list: { id: number; name: string }[]) =>
|
||||
|
||||
Reference in New Issue
Block a user