feat: Add axum-extra dependency and implement typed headers
feat: Define unique index on users table for email and fix minor syntax error refactor: Update permissions_guard to use claims from JWT and improve user retrieval refactor: Modify user-related service methods to accept user details directly fix: Update token generation functions to include user ID and permissions test: Update Google OAuth flow tests to reflect changes in token generation
This commit is contained in:
@@ -25,13 +25,13 @@ pub async fn get_detail_gacha_claim(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadDetailGachaClaims],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaClaimService::get_gacha_claim_by_id(&state, id).await,
|
||||
Ok((_user, state)) => GachaClaimService::get_gacha_claim_by_id(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -54,13 +54,13 @@ pub async fn post_create_gacha_claim(
|
||||
Json(payload): Json<GachaClaimRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::CreateGachaClaims],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaClaimService::create_gacha_claim(&state, payload).await,
|
||||
Ok((_user, state)) => GachaClaimService::create_gacha_claim(&state, payload).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ pub async fn get_gacha_item_list(
|
||||
Query(meta): Query<MetaRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadListGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::get_gacha_item_list(&state, meta).await,
|
||||
Ok((_user, state)) => GachaItemService::get_gacha_item_list(&state, meta).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -65,13 +65,13 @@ pub async fn get_gacha_item_by_id(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadDetailGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::get_gacha_item_by_id(&state, id).await,
|
||||
Ok((_user, state)) => GachaItemService::get_gacha_item_by_id(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -94,13 +94,13 @@ pub async fn post_create_gacha_item(
|
||||
Json(payload): Json<GachaItemRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::CreateGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::create_gacha_item(&state, payload).await,
|
||||
Ok((_user, state)) => GachaItemService::create_gacha_item(&state, payload).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -124,13 +124,13 @@ pub async fn put_update_gacha_item(
|
||||
Json(payload): Json<GachaItemUpdateRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::UpdateGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::update_gacha_item(&state, payload, id).await,
|
||||
Ok((_user, state)) => GachaItemService::update_gacha_item(&state, payload, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -152,13 +152,13 @@ pub async fn delete_gacha_item(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::DeleteGachaItems],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaItemService::delete_gacha_item(&state, id).await,
|
||||
Ok((_user, state)) => GachaItemService::delete_gacha_item(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ pub async fn get_detail_gacha_roll(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ReadDetailGachaRolls],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaRollService::get_gacha_roll_by_id(&state, id).await,
|
||||
Ok((_user, state)) => GachaRollService::get_gacha_roll_by_id(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -54,13 +54,13 @@ pub async fn post_create_gacha_roll(
|
||||
Json(payload): Json<GachaRollRequestDto>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::CreateGachaRolls],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaRollService::create_gacha_roll(&state, payload).await,
|
||||
Ok((_user, state)) => GachaRollService::create_gacha_roll(&state, payload).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -81,13 +81,13 @@ pub async fn post_execute_gacha_roll(
|
||||
Extension(state): Extension<AppState>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers.clone(),
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::ExecuteGachaRolls],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaRollService::execute_roll_once(headers, &state).await,
|
||||
Ok((_user, state)) => GachaRollService::execute_roll_once(headers, &state).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
@@ -110,13 +110,13 @@ pub async fn delete_gacha_roll(
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
match permissions_guard(
|
||||
&headers,
|
||||
state.clone(),
|
||||
headers,
|
||||
Extension(state),
|
||||
vec![PermissionsEnum::DeleteGachaRolls],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => GachaRollService::soft_delete_gacha_roll(&state, id).await,
|
||||
Ok((_user, state)) => GachaRollService::soft_delete_gacha_roll(&state, id).await,
|
||||
Err(response) => response,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user