Add auth
This commit is contained in:
parent
e1ba3d44c7
commit
dda356ea00
8 changed files with 60 additions and 0 deletions
|
|
@ -6,12 +6,20 @@ use crate::errors::SyncServerError;
|
|||
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_documents(
|
||||
TypedHeader(auth_header): TypedHeader<Authorization<Bearer>>,
|
||||
Path(vault_id): Path<VaultId>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Vec<DocumentVersionWithoutContent>>, SyncServerError> {
|
||||
auth(&state, auth_header.token())?;
|
||||
|
||||
let latest_version = state
|
||||
.database
|
||||
.get_latest_documents(&vault_id, None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue