feat: implement edit user / username

This commit is contained in:
Paul Makles
2022-02-03 22:52:04 +00:00
parent 1d5800a3b8
commit 63064cc9bb
4 changed files with 94 additions and 164 deletions

View File

@@ -18,9 +18,10 @@ pub struct Data {
pub async fn req(
db: &State<Database>,
account: Account,
user: User,
mut user: User,
data: Json<Data>,
) -> Result<EmptyResponse> {
let data = data.into_inner();
account.verify_password(&data.password).map_err(|_| Error::InvalidCredentials)?;
user.update_username(db, &data.username).await
user.update_username(db, data.username).await.map(|_| EmptyResponse)
}