check image mime type
This commit is contained in:
parent
4d06d08a03
commit
49c03b167e
5 changed files with 36 additions and 23 deletions
|
|
@ -255,11 +255,10 @@ let get_avatar user_id =
|
|||
let upload_avatar files user_id =
|
||||
match files with
|
||||
| [] -> Error "No file provided"
|
||||
| [ (_, content) ] ->
|
||||
if not (is_valid_image content) then Error "Invalid image"
|
||||
else
|
||||
let^ () = Db.exec Q.upload_avatar (content, user_id) in
|
||||
Ok ()
|
||||
| [ (name_opt, content) ] ->
|
||||
let* _name, _alt, content = clean_image (name_opt, "avatar", content) in
|
||||
let^ () = Db.exec Q.upload_avatar (content, user_id) in
|
||||
Ok ()
|
||||
| _files -> Error "More than one file provided"
|
||||
|
||||
let is_admin user_id =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue