Skip to content

Commit

Permalink
refactor: Removing unneeded return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
bush1D3v committed Jun 28, 2024
1 parent 7719676 commit b4a5bdb
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/modules/user/user_controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,33 +228,31 @@ async fn login_user(
email: user.email,
password: user.password,
};
return match login_user_service(web::Json(user), pg_pool, true).await {
match login_user_service(web::Json(user), pg_pool, true).await {
Ok(tokens) => HttpResponse::Ok().json(LoginUserControllerResponse {
access_token: tokens.access_token,
access_expires_in: tokens.access_expires_in,
refresh_token: tokens.refresh_token,
refresh_expires_in: tokens.refresh_expires_in,
}),
Err(e) => e,
};
}
}
Err(e) => return e,
Err(e) => e,
},
Err(_) => match login_user_service(body, pg_pool, false).await {
Ok(tokens) => HttpResponse::Ok().json(LoginUserControllerResponse {
access_token: tokens.access_token,
access_expires_in: tokens.access_expires_in,
refresh_token: tokens.refresh_token,
refresh_expires_in: tokens.refresh_expires_in,
}),
Err(e) => e,
},
Err(_) => {
return match login_user_service(body, pg_pool, false).await {
Ok(tokens) => HttpResponse::Ok().json(LoginUserControllerResponse {
access_token: tokens.access_token,
access_expires_in: tokens.access_expires_in,
refresh_token: tokens.refresh_token,
refresh_expires_in: tokens.refresh_expires_in,
}),
Err(e) => e,
}
}
}
}
Err(e) => return HttpResponse::BadRequest().json(e),
};
Err(e) => HttpResponse::BadRequest().json(e),
}
}

#[derive(ToSchema, Serialize, Deserialize)]
Expand Down Expand Up @@ -357,7 +355,7 @@ async fn detail_user(
Ok(user_id) => user_id,
Err(e) => return e,
};
return match Redis::get_redis(&redis_pool, &user_id).await {
match Redis::get_redis(&redis_pool, &user_id).await {
Ok(redis_user) => match UserSerdes::serde_string_to_json(&redis_user) {
Ok(user) => {
let user = DetailUserDTO {
Expand Down Expand Up @@ -386,5 +384,5 @@ async fn detail_user(
},
Err(e) => e,
},
};
}
}

0 comments on commit b4a5bdb

Please sign in to comment.