vtx_sdk/modules/auth/context.rs
1//! Host-side context helpers.
2
3use crate::bindings::vtx::api::{vtx_auth_types::CurrentUser, vtx_context};
4
5pub type CurrentUserInfo = CurrentUser;
6
7/// Retrieves the user from the current request context, if present.
8pub fn current_user() -> Option<CurrentUser> {
9 vtx_context::get_current_user()
10}
11
12pub trait CurrentUserExt {
13 fn is_in_group(&self, group: &str) -> bool;
14}
15
16impl CurrentUserExt for CurrentUser {
17 fn is_in_group(&self, group: &str) -> bool {
18 self.groups.iter().any(|g| g == group)
19 }
20}