Skip to content

Commit

Permalink
fix(webserver): Set max avatar size
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Mar 29, 2024
1 parent 92224a6 commit 87babd8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ee/tabby-webserver/src/service/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ impl AuthenticationService for AuthenticationServiceImpl {
}

async fn update_user_avatar(&self, id: &ID, avatar: Option<Box<[u8]>>) -> Result<()> {
if avatar.as_ref().is_some_and(|v| v.len() > 512 * 1024) {
return Err(anyhow!("Avatar cannot be larger than 512KB").into());
}

Check warning on line 196 in ee/tabby-webserver/src/service/auth.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/auth.rs#L194-L196

Added lines #L194 - L196 were not covered by tests
let id = id.as_rowid()?;
self.db.update_user_avatar(id, avatar).await?;
Ok(())
Expand Down

0 comments on commit 87babd8

Please sign in to comment.