Make small changes and renaming

This commit is contained in:
ManyTheFish 2022-05-31 15:23:17 +02:00
parent 151f494110
commit b3c8915702
4 changed files with 18 additions and 22 deletions

View file

@ -69,7 +69,7 @@ pub async fn get_api_key(
let key = path.into_inner().key;
let res = tokio::task::spawn_blocking(move || -> Result<_, AuthControllerError> {
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.try_get_uid_from_sha(&key))?;
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.get_uid_from_sha(&key))?;
let key = auth_controller.get_key(uid)?;
Ok(KeyView::from_key(key, &auth_controller))
@ -88,7 +88,7 @@ pub async fn patch_api_key(
let key = path.into_inner().key;
let body = body.into_inner();
let res = tokio::task::spawn_blocking(move || -> Result<_, AuthControllerError> {
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.try_get_uid_from_sha(&key))?;
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.get_uid_from_sha(&key))?;
let key = auth_controller.update_key(uid, body)?;
Ok(KeyView::from_key(key, &auth_controller))
@ -105,7 +105,7 @@ pub async fn delete_api_key(
) -> Result<HttpResponse, ResponseError> {
let key = path.into_inner().key;
tokio::task::spawn_blocking(move || {
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.try_get_uid_from_sha(&key))?;
let uid = Uuid::parse_str(&key).or_else(|_| auth_controller.get_uid_from_sha(&key))?;
auth_controller.delete_key(uid)
})
.await