Skip to content

Commit 51ed899

Browse files
committed
is_claimed
1 parent 60e0cfe commit 51ed899

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/api_run/src/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async fn post_inner(
6666
};
6767

6868
// If a project is unclaimed, don't check permissions
69-
if !query_project.is_unclaimed(conn_lock!(context))? {
69+
if query_project.is_claimed(conn_lock!(context))? {
7070
if let Some(auth_user) = auth_user.as_ref() {
7171
query_project.try_allowed(&context.rbac, auth_user, Permission::Create)?;
7272
} else {

lib/bencher_schema/src/model/organization/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ impl QueryOrganization {
9191
if let Ok(query_organization) =
9292
Self::from_resource_id(conn_lock!(context), &project_slug.clone().into())
9393
{
94-
// If the project is part of an organization that is unclaimed,
95-
// then the project can have anonymous reports.
96-
return if query_organization.is_unclaimed(conn_lock!(context))? {
97-
Ok(query_organization)
98-
} else {
94+
// If the project is part of an organization that is claimed,
95+
// then the project can not have anonymous reports.
96+
return if query_organization.is_claimed(conn_lock!(context))? {
9997
Err(unauthorized_error(format!(
10098
"This project ({project_slug}) has already been claimed."
10199
)))
100+
} else {
101+
Ok(query_organization)
102102
};
103103
}
104104

@@ -224,10 +224,10 @@ impl QueryOrganization {
224224
.map_err(forbidden_error)
225225
}
226226

227-
pub fn is_unclaimed(&self, conn: &mut DbConnection) -> Result<bool, HttpError> {
227+
pub fn is_claimed(&self, conn: &mut DbConnection) -> Result<bool, HttpError> {
228228
let total_members = QueryOrganizationRole::count(conn, self.id)?;
229229
// If the organization that has zero members, then it is unclaimed.
230-
Ok(total_members == 0)
230+
Ok(total_members > 0)
231231
}
232232

233233
pub fn into_json(self) -> JsonOrganization {

lib/bencher_schema/src/model/project/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ impl QueryProject {
386386
.map_err(forbidden_error)
387387
}
388388

389-
pub fn is_unclaimed(&self, conn: &mut DbConnection) -> Result<bool, HttpError> {
389+
pub fn is_claimed(&self, conn: &mut DbConnection) -> Result<bool, HttpError> {
390390
let query_organization = QueryOrganization::get(conn, self.organization_id)?;
391-
query_organization.is_unclaimed(conn)
391+
query_organization.is_claimed(conn)
392392
}
393393

394394
#[cfg(feature = "plus")]

0 commit comments

Comments
 (0)