server: Add support for creating a user through LDAP

This commit is contained in:
Valentin Tolmer
2022-10-20 10:01:34 +02:00
committed by nitnelave
parent 2477439ecc
commit 27144ee37e
2 changed files with 156 additions and 3 deletions

View File

@@ -98,6 +98,16 @@ impl From<&JpegPhoto> for sea_query::Value {
}
}
impl TryFrom<&[u8]> for JpegPhoto {
type Error = anyhow::Error;
fn try_from(bytes: &[u8]) -> anyhow::Result<Self> {
// Confirm that it's a valid Jpeg, then store only the bytes.
image::io::Reader::with_format(std::io::Cursor::new(bytes), image::ImageFormat::Jpeg)
.decode()?;
Ok(JpegPhoto(bytes.to_vec()))
}
}
impl TryFrom<Vec<u8>> for JpegPhoto {
type Error = anyhow::Error;
fn try_from(bytes: Vec<u8>) -> anyhow::Result<Self> {