Add auth
This commit is contained in:
parent
e1ba3d44c7
commit
dda356ea00
1 changed files with 60 additions and 0 deletions
|
|
@ -9,12 +9,20 @@ use anyhow::anyhow;
|
|||
use axum::extract::Path;
|
||||
use axum::extract::State;
|
||||
use axum::Json;
|
||||
use axum_extra::headers::authorization::Bearer;
|
||||
use axum_extra::headers::Authorization;
|
||||
use axum_extra::TypedHeader;
|
||||
|
||||
use super::auth::auth;
|
||||
|
||||
#[axum::debug_handler]
|
||||
pub async fn fetch_latest_document_version(
|
||||
TypedHeader(auth_header): TypedHeader<Authorization<Bearer>>,
|
||||
Path((vault_id, document_id)): Path<(VaultId, DocumentId)>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<DocumentVersion>, SyncServerError> {
|
||||
auth(&state, auth_header.token())?;
|
||||
|
||||
let latest_version = state
|
||||
.database
|
||||
.get_latest_document_version(&vault_id, &document_id, None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue