Checks if the caller has access to the given user. Admins and controllers have access to all users.
(&self, user: &User, ctx: &CallContext)
| 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 | /// |
no test coverage detected