chore: fix typo
This commit is contained in:
parent
8bd4d6f107
commit
d0872f1868
|
@ -29,7 +29,7 @@ pub async fn handle(
|
|||
Err(err) => {
|
||||
return match err {
|
||||
Error::UserNotFound => Err(ServerError::AuthError(AuthError::UserNotFound)),
|
||||
_ => Err(ServerError::AuthError(AuthError::UnknowError(
|
||||
_ => Err(ServerError::AuthError(AuthError::UnknownError(
|
||||
err.to_string(),
|
||||
))),
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use axum::routing::get;
|
||||
|
||||
pub mod login;
|
||||
pub mod register;
|
||||
pub mod whoami;
|
||||
|
||||
pub fn app() -> axum::Router {
|
||||
use axum::routing::post;
|
||||
use axum::routing::{get, post};
|
||||
|
||||
axum::Router::new()
|
||||
.route("/login", post(login::handle))
|
||||
|
|
|
@ -48,7 +48,7 @@ pub async fn handle(
|
|||
return Err(ServerError::AuthError(AuthError::UserAlreadyExists));
|
||||
}
|
||||
|
||||
return Err(ServerError::AuthError(AuthError::UnknowError(
|
||||
return Err(ServerError::AuthError(AuthError::UnknownError(
|
||||
e.to_string(),
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ pub async fn handle(
|
|||
Err(err) => match err {
|
||||
Error::UserNotFound => return Err(ServerError::AuthError(AuthError::UserNotFound)),
|
||||
_ => {
|
||||
return Err(ServerError::AuthError(AuthError::UnknowError(
|
||||
return Err(ServerError::AuthError(AuthError::UnknownError(
|
||||
err.to_string(),
|
||||
)))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use homedisk_types::errors::{FsError, ServerError};
|
||||
|
||||
pub mod list;
|
||||
pub mod upload;
|
||||
|
||||
|
@ -11,7 +9,9 @@ pub fn app() -> axum::Router {
|
|||
.route("/upload", post(upload::handle))
|
||||
}
|
||||
|
||||
pub fn validate_path(path: &str) -> Result<(), ServerError> {
|
||||
pub fn validate_path(path: &str) -> Result<(), homedisk_types::errors::ServerError> {
|
||||
use homedisk_types::errors::{FsError, ServerError};
|
||||
|
||||
// `path` cannot contain `..`
|
||||
// to prevent attack attempts because by using a `..` you can access the previous folder
|
||||
if path.contains("..") {
|
||||
|
|
|
@ -18,7 +18,7 @@ pub async fn find_user(db: Database, user_id: String) -> Result<User, ServerErro
|
|||
homedisk_database::Error::UserNotFound => {
|
||||
Err(ServerError::AuthError(AuthError::UserNotFound))
|
||||
}
|
||||
_ => Err(ServerError::AuthError(AuthError::UnknowError(
|
||||
_ => Err(ServerError::AuthError(AuthError::UnknownError(
|
||||
err.to_string(),
|
||||
))),
|
||||
},
|
||||
|
|
|
@ -48,7 +48,9 @@ impl User {
|
|||
///
|
||||
/// let user = User::new("medzik", "whatever");
|
||||
///
|
||||
/// user.user_dir("/home/homedisk"); // will return `/home/homedisk/medzik`
|
||||
/// let dir = user.user_dir("/home/homedisk"); // will return `/home/homedisk/medzik`
|
||||
///
|
||||
/// assert_eq!(dir, "/home/homedisk/medzik")
|
||||
/// ```
|
||||
pub fn user_dir(&self, storage: &str) -> String {
|
||||
let path = format!(
|
||||
|
|
|
@ -23,6 +23,6 @@ pub enum Error {
|
|||
#[error("invalid jwt token")]
|
||||
InvalidToken,
|
||||
|
||||
#[error("unknow error")]
|
||||
UnknowError(String),
|
||||
#[error("unknown error")]
|
||||
UnknownError(String),
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ impl axum::response::IntoResponse for ServerError {
|
|||
AuthError::PasswordTooShort => StatusCode::NOT_ACCEPTABLE,
|
||||
AuthError::TokenGenerate => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
AuthError::InvalidToken => StatusCode::BAD_REQUEST,
|
||||
AuthError::UnknowError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
AuthError::UnknownError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
},
|
||||
Self::FsError(ref err) => match err {
|
||||
FsError::FileAlreadyExists => StatusCode::BAD_REQUEST,
|
||||
|
|
Loading…
Reference in New Issue