user
This commit is contained in:
parent
4193b37b6b
commit
95c5592170
4 changed files with 54 additions and 1 deletions
|
@ -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)})
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue