mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 05:38:19 +00:00
refactor(backend-api)!: Rename GetCurrentUser, add GetCurrentUserWithNamespaces
Make the GetCurrentUser query only return a plain user without namespaces. Rename the current function/query to GetCurrentUserWithNamespaces, get_current_user_with_namespaces. This makes more sense , since the namespace query adds quite a lot of extra work.
This commit is contained in:
@@ -164,7 +164,15 @@ pub async fn tag_package_release(
|
||||
.map(|r| r.tag_package_release)
|
||||
}
|
||||
|
||||
/// Get the currently logged in used, together with all accessible namespaces.
|
||||
/// Get the currently logged in user.
|
||||
pub async fn current_user(client: &WasmerClient) -> Result<Option<types::User>, anyhow::Error> {
|
||||
client
|
||||
.run_graphql(types::GetCurrentUser::build(()))
|
||||
.await
|
||||
.map(|x| x.viewer)
|
||||
}
|
||||
|
||||
/// Get the currently logged in user, together with all accessible namespaces.
|
||||
///
|
||||
/// You can optionally filter the namespaces by the user role.
|
||||
pub async fn current_user_with_namespaces(
|
||||
@@ -172,9 +180,9 @@ pub async fn current_user_with_namespaces(
|
||||
namespace_role: Option<types::GrapheneRole>,
|
||||
) -> Result<types::UserWithNamespaces, anyhow::Error> {
|
||||
client
|
||||
.run_graphql(types::GetCurrentUser::build(types::GetCurrentUserVars {
|
||||
namespace_role,
|
||||
}))
|
||||
.run_graphql(types::GetCurrentUserWithNamespaces::build(
|
||||
types::GetCurrentUserWithNamespacesVars { namespace_role },
|
||||
))
|
||||
.await?
|
||||
.viewer
|
||||
.context("not logged in")
|
||||
@@ -544,9 +552,11 @@ pub async fn user_accessible_apps(
|
||||
|
||||
// Get all aps in user-accessible namespaces.
|
||||
let namespace_res = client
|
||||
.run_graphql(types::GetCurrentUser::build(types::GetCurrentUserVars {
|
||||
namespace_role: None,
|
||||
}))
|
||||
.run_graphql(types::GetCurrentUserWithNamespaces::build(
|
||||
types::GetCurrentUserWithNamespacesVars {
|
||||
namespace_role: None,
|
||||
},
|
||||
))
|
||||
.await?;
|
||||
let active_user = namespace_res.viewer.context("not logged in")?;
|
||||
let namespace_names = active_user
|
||||
@@ -655,9 +665,11 @@ pub async fn user_namespaces(
|
||||
client: &WasmerClient,
|
||||
) -> Result<Vec<types::Namespace>, anyhow::Error> {
|
||||
let user = client
|
||||
.run_graphql(types::GetCurrentUser::build(types::GetCurrentUserVars {
|
||||
namespace_role: None,
|
||||
}))
|
||||
.run_graphql(types::GetCurrentUserWithNamespaces::build(
|
||||
types::GetCurrentUserWithNamespacesVars {
|
||||
namespace_role: None,
|
||||
},
|
||||
))
|
||||
.await?
|
||||
.viewer
|
||||
.context("not logged in")?;
|
||||
|
||||
Reference in New Issue
Block a user