disallow editing profile for banned users

This commit is contained in:
Brandon Thomas committed 2021-09-03 05:09:33 -04:00
1 parent ecbc76d3b7
commit 5bafb0503f
2 files changed
+8

No files matched your search

@@ -116,6 +116,11 @@ pub async fn edit_profile_handler(
}
};
if user_session.is_banned {
// Banned users can't edit anything
return Err(EditProfileError::NotAuthorized);
}
let user_lookup_result =
get_user_profile_by_username(&path.username, &server_state.mysql_pool)
.await;
@@ -39,6 +39,7 @@ pub struct InferW2lSuccessResponse {
#[derive(Debug, Display)]
pub enum InferW2lError {
BadInput(String),
NotAuthorized,
ServerError,
}
@@ -47,6 +48,7 @@ impl ResponseError for InferW2lError {
match *self {
InferW2lError::BadInput(_) => StatusCode::BAD_REQUEST,
InferW2lError::ServerError => StatusCode::INTERNAL_SERVER_ERROR,
InferW2lError::NotAuthorized => StatusCode::UNAUTHORIZED,
}
}
@@ -54,6 +56,7 @@ impl ResponseError for InferW2lError {
let error_reason = match self {
InferW2lError::BadInput(reason) => reason.to_string(),
InferW2lError::ServerError => "server error".to_string(),
InferW2lError::NotAuthorized => "not authorized".to_string(),
};
to_simple_json_error(&error_reason, self.status_code())