vtx_sdk/host/context.rs
1//! Host-side context helpers.
2
3use crate::bindings::vtx::api::{auth_types::CurrentUser, context};
4
5pub type CurrentUserInfo = CurrentUser;
6
7/// 获取当前请求上下文中的用户(若存在)。
8pub fn current_user() -> Option<CurrentUser> {
9 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}