1
0
Fork 0

Merge branch 'jjlin-json-response'

Dieser Commit ist enthalten in:
Daniel García 2023-01-09 19:11:00 +01:00
Commit 23f5a62d61
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: FC8A7D14C3CD543A

Datei anzeigen

@ -660,9 +660,9 @@ async fn delete_account(data: JsonUpcase<PasswordData>, headers: Headers, mut co
} }
#[get("/accounts/revision-date")] #[get("/accounts/revision-date")]
fn revision_date(headers: Headers) -> String { fn revision_date(headers: Headers) -> JsonResult {
let revision_date = headers.user.updated_at.timestamp_millis(); let revision_date = headers.user.updated_at.timestamp_millis();
revision_date.to_string() Ok(Json(json!(revision_date)))
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -792,14 +792,11 @@ async fn rotate_api_key(data: JsonUpcase<SecretVerificationRequest>, headers: He
} }
#[get("/devices/knowndevice/<email>/<uuid>")] #[get("/devices/knowndevice/<email>/<uuid>")]
async fn get_known_device(email: String, uuid: String, mut conn: DbConn) -> String { async fn get_known_device(email: String, uuid: String, mut conn: DbConn) -> JsonResult {
// This endpoint doesn't have auth header // This endpoint doesn't have auth header
let mut result = false;
if let Some(user) = User::find_by_mail(&email, &mut conn).await { if let Some(user) = User::find_by_mail(&email, &mut conn).await {
match Device::find_by_uuid_and_user(&uuid, &user.uuid, &mut conn).await { result = Device::find_by_uuid_and_user(&uuid, &user.uuid, &mut conn).await.is_some();
Some(_) => String::from("true"),
_ => String::from("false"),
}
} else {
String::from("false")
} }
Ok(Json(json!(result)))
} }