Skip to content

Commit b5171bf

Browse files
committed
feat: [#615] authorization layer added for add torrent method of the torrent service
1 parent 1c607c2 commit b5171bf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/services/authorization.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub enum ACTION {
4545
GetLicensePage,
4646
GetImageByUrl,
4747
GetPublicSettings,
48+
AddTorrent,
4849
}
4950

5051
pub struct Service {
@@ -184,10 +185,12 @@ impl CasbinConfiguration {
184185
admin, DeleteTorrent
185186
admin, BanUser
186187
admin, GetImageByUrl
188+
admin, AddTorrent
187189
registered, GetCategories
188190
registered, GetImageByUrl
189191
registered, GetPublicSettings
190192
registered, GetTags
193+
registered, AddTorrent
191194
guest, GetCategories
192195
guest, GetTags
193196
guest, GetAboutPage

src/services/torrent.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ impl Index {
134134
add_torrent_req: AddTorrentRequest,
135135
user_id: UserId,
136136
) -> Result<AddTorrentResponse, ServiceError> {
137-
// Guard that the users exists
138-
let _user = self.user_repository.get_compact(&user_id).await?;
137+
self.authorization_service
138+
.authorize(ACTION::AddTorrent, Some(user_id))
139+
.await?;
139140

140141
let metadata = self.validate_and_build_metadata(&add_torrent_req).await?;
141142

0 commit comments

Comments
 (0)