This commit is contained in:
JMARyA 2024-08-08 14:28:23 +02:00
parent 4193b37b6b
commit 95c5592170
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 54 additions and 1 deletions

View file

@ -27,7 +27,7 @@ impl Artist {
}
/// Gets the image of an artist or `None` if it can't be found.
///
///
/// This function gets a track from the artist. It then expects the folder structure to be `Artist/Album/Track.ext` and searches for an image file named `artist` in the artist folder.
pub async fn get_image_of(id: &str) -> Option<String> {
let track_path = Track::find_one(doc! { "artist_id": reference_of!(Artist, id)})

View file

@ -68,6 +68,23 @@ impl User {
Some(u.session().await)
}
/// Change the password of a `User`
pub async fn passwd(&mut self, old: &str, new: &str) -> Result<(), ()> {
if self.verify_pw(old) {
self.update(&json!(
{
"password": bcrypt::hash(new, bcrypt::DEFAULT_COST).unwrap()
}
))
.await
.map_err(|_| ())?;
return Ok(());
}
Err(())
}
pub async fn session(&self) -> Session {
let s = Session {
_id: uuid::Uuid::new_v4().to_string(),