Change "client key" to "client id" (#3130)
In #3118 @ryneeverett mentioned that "key" suggests that this is a secret, when in truth it's just a user identifier. So "ID" is a better word for it than "key".
This commit is contained in:
committed by
GitHub
parent
8097e28318
commit
7f68441916
@@ -1,4 +1,4 @@
|
||||
use crate::server::ClientKey;
|
||||
use crate::server::ClientId;
|
||||
use crate::storage::Storage;
|
||||
use crate::ServerConfig;
|
||||
use actix_web::{error, http::StatusCode, web, HttpRequest, Result, Scope};
|
||||
@@ -18,8 +18,8 @@ pub(crate) const SNAPSHOT_CONTENT_TYPE: &str = "application/vnd.taskchampion.sna
|
||||
/// The header name for version ID
|
||||
pub(crate) const VERSION_ID_HEADER: &str = "X-Version-Id";
|
||||
|
||||
/// The header name for client key
|
||||
pub(crate) const CLIENT_KEY_HEADER: &str = "X-Client-Key";
|
||||
/// The header name for client id
|
||||
pub(crate) const CLIENT_ID_HEADER: &str = "X-Client-Id";
|
||||
|
||||
/// The header name for parent version ID
|
||||
pub(crate) const PARENT_VERSION_ID_HEADER: &str = "X-Parent-Version-Id";
|
||||
@@ -46,15 +46,15 @@ fn failure_to_ise(err: anyhow::Error) -> impl actix_web::ResponseError {
|
||||
error::InternalError::new(err, StatusCode::INTERNAL_SERVER_ERROR)
|
||||
}
|
||||
|
||||
/// Get the client key
|
||||
fn client_key_header(req: &HttpRequest) -> Result<ClientKey> {
|
||||
/// Get the client id
|
||||
fn client_id_header(req: &HttpRequest) -> Result<ClientId> {
|
||||
fn badrequest() -> error::Error {
|
||||
error::ErrorBadRequest("bad x-client-id")
|
||||
}
|
||||
if let Some(client_key_hdr) = req.headers().get(CLIENT_KEY_HEADER) {
|
||||
let client_key = client_key_hdr.to_str().map_err(|_| badrequest())?;
|
||||
let client_key = ClientKey::parse_str(client_key).map_err(|_| badrequest())?;
|
||||
Ok(client_key)
|
||||
if let Some(client_id_hdr) = req.headers().get(CLIENT_ID_HEADER) {
|
||||
let client_id = client_id_hdr.to_str().map_err(|_| badrequest())?;
|
||||
let client_id = ClientId::parse_str(client_id).map_err(|_| badrequest())?;
|
||||
Ok(client_id)
|
||||
} else {
|
||||
Err(badrequest())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user