Skip to content

Commit

Permalink
fix(webserver): Set max avatar size (TabbyML#1746)
Browse files Browse the repository at this point in the history
* fix(webserver): Set max avatar size

* Update ee/tabby-webserver/src/service/auth.rs

---------

Co-authored-by: Meng Zhang <[email protected]>
  • Loading branch information
boxbeam and wsxiaoys authored Mar 29, 2024
1 parent 92224a6 commit 4e5bbec
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!("The image you are attempting to upload is too large. Please ensure the file size is under 512KB").into());
}
let id = id.as_rowid()?;
self.db.update_user_avatar(id, avatar).await?;
Ok(())
Expand Down

0 comments on commit 4e5bbec

Please sign in to comment.