Skip to content

Commit

Permalink
fix: [torrust#230] make sure user exist in upload torrent endpoint
Browse files Browse the repository at this point in the history
We get the user ID from the Json Web Token, but that does not mean the user actually exists. The session could be valid, but the user could have been removed from the database.
  • Loading branch information
josecelano committed Jul 3, 2023
1 parent fe25778 commit a534e38
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/services/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ impl Index {
/// * Unable to insert the torrent into the database.
/// * Unable to add the torrent to the whitelist.
pub async fn add_torrent(&self, mut torrent_request: AddTorrentRequest, user_id: UserId) -> Result<TorrentId, ServiceError> {
let _user = self.user_repository.get_compact(&user_id).await?;

torrent_request.torrent.set_announce_urls(&self.configuration).await;

let category = self
Expand Down

0 comments on commit a534e38

Please sign in to comment.