From 4c75f243b641fbee0c641ae2ed86cb66400c59d0 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 9 Dec 2022 20:17:39 +0100 Subject: [PATCH] display account without refresh tokens as non refreshed --- backend/windmill-api/openapi.yaml | 5 +++++ backend/windmill-api/src/resources.rs | 5 ++++- backend/windmill-api/src/variables.rs | 6 ++++-- backend/windmill-common/src/variables.rs | 1 + frontend/src/routes/resources.svelte | 4 ++-- frontend/src/routes/variables.svelte | 4 ++-- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index f130eb2267..f7375f5b8b 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -4273,6 +4273,8 @@ components: type: string is_linked: type: boolean + is_refreshed: + type: boolean required: - workspace_id - path @@ -4568,6 +4570,8 @@ components: type: string is_linked: type: boolean + is_refreshed: + type: boolean account: type: number required: @@ -4575,6 +4579,7 @@ components: - resource_type - is_oauth - is_linked + - is_refreshed ResourceType: type: object diff --git a/backend/windmill-api/src/resources.rs b/backend/windmill-api/src/resources.rs index 1e48765d73..5a9c4a9175 100644 --- a/backend/windmill-api/src/resources.rs +++ b/backend/windmill-api/src/resources.rs @@ -83,6 +83,7 @@ pub struct ListableResource { pub resource_type: String, pub extra_perms: serde_json::Value, pub is_linked: Option, + pub is_refreshed: Option, pub is_oauth: Option, pub is_expired: Option, pub refresh_error: Option, @@ -126,6 +127,7 @@ async fn list_resources( "resource.extra_perms", "(now() > account.expires_at) as is_expired", "variable.path IS NOT NULL as is_linked", + "account.refresh_token != '' as is_refreshed", "variable.is_oauth", "variable.account", "account.refresh_error", @@ -167,7 +169,8 @@ async fn get_resource( let resource_o = sqlx::query_as!( ListableResource, - "SELECT resource.*, (now() > account.expires_at) as is_expired, account.refresh_error, + "SELECT resource.*, (now() > account.expires_at) as is_expired, account.refresh_token != '' as is_refreshed, + account.refresh_error, variable.path IS NOT NULL as is_linked, variable.is_oauth as \"is_oauth?\", variable.account diff --git a/backend/windmill-api/src/variables.rs b/backend/windmill-api/src/variables.rs index df045b8340..b12871838f 100644 --- a/backend/windmill-api/src/variables.rs +++ b/backend/windmill-api/src/variables.rs @@ -85,7 +85,8 @@ async fn list_variables( "SELECT variable.workspace_id, variable.path, CASE WHEN is_secret IS TRUE THEN null ELSE variable.value::text END as value, is_secret, variable.description, variable.extra_perms, account, is_oauth, (now() > account.expires_at) as is_expired, account.refresh_error, - resource.path IS NOT NULL as is_linked + resource.path IS NOT NULL as is_linked, + account.refresh_token != '' as is_refreshed from variable LEFT JOIN account ON variable.account = account.id AND account.workspace_id = variable.workspace_id LEFT JOIN resource ON resource.path = variable.path AND resource.workspace_id = variable.workspace_id @@ -117,7 +118,8 @@ async fn get_variable( let variable_o = sqlx::query_as::<_, ListableVariable>( "SELECT variable.*, (now() > account.expires_at) as is_expired, account.refresh_error, - resource.path IS NOT NULL as is_linked + resource.path IS NOT NULL as is_linked, + account.refresh_token != '' as is_refreshed from variable LEFT JOIN account ON variable.account = account.id LEFT JOIN resource ON resource.path = variable.path AND resource.workspace_id = variable.workspace_id diff --git a/backend/windmill-common/src/variables.rs b/backend/windmill-common/src/variables.rs index 653615149f..a24f64e0d6 100644 --- a/backend/windmill-common/src/variables.rs +++ b/backend/windmill-common/src/variables.rs @@ -29,6 +29,7 @@ pub struct ListableVariable { pub account: Option, pub is_oauth: Option, pub is_expired: Option, + pub is_refreshed: Option, pub refresh_error: Option, pub is_linked: Option, } diff --git a/frontend/src/routes/resources.svelte b/frontend/src/routes/resources.svelte index 6dffa93217..b62efa653d 100644 --- a/frontend/src/routes/resources.svelte +++ b/frontend/src/routes/resources.svelte @@ -321,7 +321,7 @@ {#if filteredItems} - {#each filteredItems as { path, description, resource_type, extra_perms, canWrite, is_oauth, is_linked, account, refresh_error, is_expired, marked }} + {#each filteredItems as { path, description, resource_type, extra_perms, canWrite, is_oauth, is_linked, account, refresh_error, is_expired, marked, is_refreshed }}