Skip to content

Commit

Permalink
控制台新增用户接口增加对角色内容校验 #136
Browse files Browse the repository at this point in the history
  • Loading branch information
heqingpan committed Sep 17, 2024
1 parent 2ac8fd0 commit 1089863
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/console/user_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ pub async fn add_user(
web::Form(user_param): web::Form<UpdateUserInfoParam>,
) -> actix_web::Result<impl Responder> {
let user: UserDto = user_param.into();
if user.roles.is_none() {
return Ok(HttpResponse::Ok().json(ApiResult::<()>::error(
"USER_ROLE_IS_EMPTY".to_string(),
Some("user roles is empty".to_owned()),
)));
}
let msg = UserManagerReq::AddUser {
user: UserDto {
username: user.username,
Expand Down
6 changes: 6 additions & 0 deletions src/console/v2/user_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ pub async fn add_user(
web::Json(user_param): web::Json<UpdateUserInfoParam>,
) -> actix_web::Result<impl Responder> {
let user: UserDto = user_param.into();
if user.roles.is_none() {
return Ok(HttpResponse::Ok().json(ApiResult::<()>::error(
"USER_ROLE_IS_EMPTY".to_string(),
Some("user roles is empty".to_owned()),
)));
}
let msg = UserManagerReq::AddUser {
user: UserDto {
username: user.username,
Expand Down

0 comments on commit 1089863

Please sign in to comment.