feat: Enhance error handling by adding Forbidden and Unknown error types
This commit is contained in:
@@ -149,9 +149,15 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
"User does not have permission to view this media.".into(),
|
||||
))
|
||||
if user_id.is_some() {
|
||||
return Err(CoreError::Forbidden(
|
||||
"User does not have permission to view this media.".into(),
|
||||
));
|
||||
} else {
|
||||
return Err(CoreError::Auth(
|
||||
"Authentication required for this action".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Permission::DeleteMedia(media_id) | Permission::EditMedia(media_id) => {
|
||||
@@ -163,7 +169,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to modify this media.".into(),
|
||||
))
|
||||
}
|
||||
@@ -189,7 +195,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to modify tags for this media.".into(),
|
||||
))
|
||||
}
|
||||
@@ -206,7 +212,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to view this album.".into(),
|
||||
))
|
||||
}
|
||||
@@ -222,7 +228,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to modify this album.".into(),
|
||||
))
|
||||
}
|
||||
@@ -237,7 +243,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to share or delete this album.".into(),
|
||||
))
|
||||
}
|
||||
@@ -253,7 +259,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to view this person.".into(),
|
||||
))
|
||||
}
|
||||
@@ -270,7 +276,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to modify this person.".into(),
|
||||
))
|
||||
}
|
||||
@@ -286,7 +292,7 @@ impl AuthorizationService for AuthorizationServiceImpl {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(CoreError::Auth(
|
||||
Err(CoreError::Forbidden(
|
||||
"User does not have permission to use this person.".into(),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user