MCPcopy Create free account
hub / github.com/dfinity/orbit / assert_user_access

Method assert_user_access

core/control-panel/impl/src/services/user.rs:196–205  ·  view source on GitHub ↗

Checks if the caller has access to the given user. Admins and controllers have access to all users.

(&self, user: &User, ctx: &CallContext)

Source from the content-addressed store, hash-verified

194 ///
195 /// Admins and controllers have access to all users.
196 fn assert_user_access(&self, user: &User, ctx: &CallContext) -> ServiceResult<()> {
197 let is_user_owner = user.identity == ctx.caller();
198 if !is_user_owner && !ctx.is_admin() && !ctx.is_controller() {
199 Err(UserError::Forbidden {
200 user: user.identity.to_text(),
201 })?
202 }
203
204 Ok(())
205 }
206
207 /// Validates that the given identity has no associated user.
208 ///

Callers 3

get_userMethod · 0.80
get_user_by_identityMethod · 0.80
remove_userMethod · 0.80

Calls 3

is_adminMethod · 0.80
is_controllerMethod · 0.80
callerMethod · 0.45

Tested by

no test coverage detected