Commit 42fb031 1 parent 836c94d commit 42fb031 Copy full SHA for 42fb031
File tree 3 files changed +7
-5
lines changed
3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ pub enum ServiceError {
109
109
InvalidTag ,
110
110
111
111
#[ display( fmt = "Unauthorized action." ) ]
112
- Unauthorized ,
112
+ UnauthorizedAction ,
113
113
114
114
#[ display( fmt = "This torrent already exists in our database." ) ]
115
115
InfoHashAlreadyExists ,
@@ -300,7 +300,7 @@ pub fn http_status_code_for_service_error(error: &ServiceError) -> StatusCode {
300
300
ServiceError :: MissingMandatoryMetadataFields => StatusCode :: BAD_REQUEST ,
301
301
ServiceError :: InvalidCategory => StatusCode :: BAD_REQUEST ,
302
302
ServiceError :: InvalidTag => StatusCode :: BAD_REQUEST ,
303
- ServiceError :: Unauthorized => StatusCode :: FORBIDDEN ,
303
+ ServiceError :: UnauthorizedAction => StatusCode :: FORBIDDEN ,
304
304
ServiceError :: InfoHashAlreadyExists => StatusCode :: BAD_REQUEST ,
305
305
ServiceError :: CanonicalInfoHashAlreadyExists => StatusCode :: CONFLICT ,
306
306
ServiceError :: OriginalInfoHashAlreadyExists => StatusCode :: CONFLICT ,
Original file line number Diff line number Diff line change @@ -79,12 +79,14 @@ impl Service {
79
79
80
80
let enforcer = self . casbin_enforcer . enforcer . read ( ) . await ;
81
81
82
- let authorize = enforcer. enforce ( ( role, action) ) . map_err ( |_| ServiceError :: Unauthorized ) ?;
82
+ let authorize = enforcer
83
+ . enforce ( ( role, action) )
84
+ . map_err ( |_| ServiceError :: UnauthorizedAction ) ?;
83
85
84
86
if authorize {
85
87
Ok ( ( ) )
86
88
} else {
87
- Err ( ServiceError :: Unauthorized )
89
+ Err ( ServiceError :: UnauthorizedAction )
88
90
}
89
91
}
90
92
Original file line number Diff line number Diff line change @@ -433,7 +433,7 @@ impl Index {
433
433
// Check if user is owner or administrator
434
434
// todo: move this to an authorization service.
435
435
if !( torrent_listing. uploader == updater. username || updater. administrator ) {
436
- return Err ( ServiceError :: Unauthorized ) ;
436
+ return Err ( ServiceError :: UnauthorizedAction ) ;
437
437
}
438
438
439
439
self . torrent_info_repository
You can’t perform that action at this time.
0 commit comments