vtx-sdk 0.1.14

Official SDK for developing VTX plugins using Rust and WebAssembly.
Documentation
//! Host-side context helpers.

use crate::bindings::vtx::api::{vtx_auth_types::CurrentUser, vtx_context};

pub type CurrentUserInfo = CurrentUser;

/// Retrieves the user from the current request context, if present.
pub fn current_user() -> Option<CurrentUser> {
    vtx_context::get_current_user()
}

pub trait CurrentUserExt {
    fn is_in_group(&self, group: &str) -> bool;
}

impl CurrentUserExt for CurrentUser {
    fn is_in_group(&self, group: &str) -> bool {
        self.groups.iter().any(|g| g == group)
    }
}