Skip to content

Commit 386e011

Browse files
committed
Improved error for non-public resources
1 parent 8beb636 commit 386e011

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/src/hierarchy.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,16 @@ pub fn check_rights(
151151
if let Ok(parent) = resource.get_parent(store) {
152152
check_rights(store, &parent, for_agent, right)
153153
} else {
154-
let for_string = if for_agent == urls::PUBLIC_AGENT {
155-
"the Public Agent".to_string()
156-
} else {
157-
for_agent.to_string()
158-
};
154+
if for_agent == urls::PUBLIC_AGENT {
155+
// resource has no parent and agent is not in rights array - check fails
156+
return Err(crate::errors::AtomicError::unauthorized(
157+
"This resource is not publicly visible. Try signing in".to_string(),
158+
));
159+
}
159160
// resource has no parent and agent is not in rights array - check fails
160161
Err(crate::errors::AtomicError::unauthorized(format!(
161162
"No {} right has been found for {} in this resource or its parents",
162-
right, for_string
163+
right, for_agent
163164
)))
164165
}
165166
}

0 commit comments

Comments
 (0)